terraform-provider-sbercloud icon indicating copy to clipboard operation
terraform-provider-sbercloud copied to clipboard

Empty scheduler_hints block in sbercloud_compute_instance causes panic

Open seleznev opened this issue 1 year ago • 0 comments

Block scheduler_hints and all their parameters are declared as optional by documentation but any of the following variants causes panic in resourceComputeSchedulerHintsHash():

  • scheduler_hints {}
    
  • scheduler_hints {
      group = null
    }
    

Nullable group is useful when you want to create a module with optional anti-affinity group.

Terraform Version

$ terraform -v
Terraform v1.4.6
on linux_amd64
+ provider registry.terraform.io/sbercloud-terraform/sbercloud v1.10.0

Affected Resource(s)

  • sbercloud_compute_instance

Terraform Configuration Files

  • resource "sbercloud_compute_instance" "basic" {
      name                        = "basic"
      image_id                    = "475decdf-7455-475e-8714-fa69cd3d778a"
      flavor_id                   = "s6.large.4"
      security_groups             = ["default"]
      system_disk_type            = "SSD"
      system_disk_size            = 20
      delete_disks_on_termination = true
      network {
        uuid = "[NETWORK_UUID]"
      }
      scheduler_hints {
        group = null
      }
    }
    
  • resource "sbercloud_compute_instance" "basic" {
      name                        = "basic"
      image_id                    = "475decdf-7455-475e-8714-fa69cd3d778a"
      flavor_id                   = "s6.large.4"
      security_groups             = ["default"]
      system_disk_type            = "SSD"
      system_disk_size            = 20
      delete_disks_on_termination = true
      network {
        uuid = "[NETWORK_UUID]"
      }
      scheduler_hints {}
    }
    

Panic Output

$ terraform plan

Planning failed. Terraform encountered an error while generating this plan.


Error: Plugin did not respond

  with sbercloud_compute_instance.basic,
  on main.tf line 8, in resource "sbercloud_compute_instance" "basic":
   8: resource "sbercloud_compute_instance" "basic" {

The plugin encountered an error, and failed to respond to the
plugin.(*GRPCProvider).PlanResourceChange call. The plugin logs may contain
more details.

Stack trace from the terraform-provider-sbercloud_v1.10.0 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 30 [running]:
github.com/sbercloud-terraform/terraform-provider-sbercloud/sbercloud.resourceComputeSchedulerHintsHash({0x0?, 0x0?})
	github.com/sbercloud-terraform/terraform-provider-sbercloud/sbercloud/resource_sbercloud_compute_instance.go:1475 +0x2fb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).hash(0x450c69?, {0x0?, 0x0?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/set.go:218 +0x2c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).add(0xc000939e20, {0x0?, 0x0}, 0x0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/set.go:198 +0x96
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ConfigFieldReader).readSet(0xc000631320, {0xc000720550, 0x1, 0x1}, 0x0?)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_reader_config.go:284 +0x4b3
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ConfigFieldReader).readField(0xc000631320, {0xc000720550?, 0x1, 0x1}, 0x0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_reader_config.go:107 +0x566
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ConfigFieldReader).ReadField(0x12ad980?, {0xc000720550?, 0x14e5726?, 0x6?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_reader_config.go:29 +0xbc
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MultiLevelFieldReader).ReadFieldExact(0xc000720540?, {0xc000720550, 0x1, 0x1}, {0x14e5726, 0x6})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/field_reader_multi.go:31 +0xa8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).get(0xc000126000, {0xc000720550, 0x1, 0x1}, 0x0?)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource_data.go:548 +0x145
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).getChange(0x0?, {0x14f20d0?, 0xf?}, 0x99?, 0xcd?)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource_data.go:524 +0x1b8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).diffChange(0xc000126000?, {0x14f20d0?, 0x1?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource_data.go:501 +0x76
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diffSet(0xc0006d32b8?, {0x14f20d0, 0xf}, 0xc00034a3c0, 0xc0006d3318, {0x170d1a0?, 0xc000126000?}, 0x0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:1241 +0x82
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diff(0xc0006d35f0?, {0x14f20d0, 0xf}, 0xc00034a3c0, 0xc000943f80, {0x170d1a0?, 0xc000126000}, 0x0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:966 +0x21f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0xc00021f530, {0x170b558, 0xc0008fa340}, 0xc0008f6ea0, 0xc000630f00, 0x0, {0x14ddcc0, 0xc000c10800}, 0x0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:525 +0x345
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x170be18?, {0x170b558?, 0xc0008fa340?}, 0xc0008f6ea0, 0x0?, {0x14ddcc0?, 0xc000c10800?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:517 +0x6c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0xc00012c060, {0x170b558, 0xc0008fa340}, 0xc0007943c0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:703 +0x931
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0xc0000d6a80, {0x170b600?, 0xc000399ce0?}, 0xc000926000)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:578 +0x2ad
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0x147bde0?, 0xc0000d6a80}, {0x170b600, 0xc000399ce0}, 0xc0002ee3c0, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:362 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000148e00, {0x170f298, 0xc000762000}, 0xc000523400, 0xc000630180, 0x20f03a8, 0x0)
	google.golang.org/[email protected]/server.go:1194 +0xcab
google.golang.org/grpc.(*Server).handleStream(0xc000148e00, {0x170f298, 0xc000762000}, 0xc000523400, 0x0)
	google.golang.org/[email protected]/server.go:1517 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:857 +0x28a

Error: The terraform-provider-sbercloud_v1.10.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Expected Behavior

Provider should not panic and work like scheduler_hints block is not defined at all.

Actual Behavior

Panic.

Steps to Reproduce

  1. terraform plan

seleznev avatar May 16 '23 02:05 seleznev