nutanix / terraform-provider-nutanix

Terraform Nutanix Provider
https://www.terraform.io/docs/providers/nutanix/
Mozilla Public License 2.0
93 stars 112 forks source link

Crash during 2nd run of windows with sysprep #638

Open davhdavh opened 10 months ago

davhdavh commented 10 months ago

Nutanix Cluster Information

Prism Element / AOS 6.5.1.6 LTS

Terraform Version

1.5.5

Affected Resource(s)

Panic Output

│ 
│   with nutanix_virtual_machine.windows[0],
│   on inline-module.tf line 300, in resource "nutanix_virtual_machine" "windows":
│  300: resource "nutanix_virtual_machine" "windows" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
│ contain more details.
╵
Stack trace from the terraform-provider-nutanix_v1.9.3 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xc820ac]
goroutine 70 [running]:
github.com/terraform-providers/terraform-provider-nutanix/nutanix.preFillResUpdateRequest(0xe5e5b0, 0xc0002aa0f0)
    github.com/terraform-providers/terraform-provider-nutanix/nutanix/resource_nutanix_virtual_machine.go:1869 +0x2c
github.com/terraform-providers/terraform-provider-nutanix/nutanix.resourceNutanixVirtualMachineUpdate({0xf81a68, 0xc000e11da0}, 0xc000fb1480, {0xcebd60, 0xc000cd00c0})
    github.com/terraform-providers/terraform-provider-nutanix/nutanix/resource_nutanix_virtual_machine.go:928 +0x356
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc00072e1c0, {0xf819f8, 0xc000c20e80}, 0x24, {0xcebd60, 0xc000cd00c0})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:375 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00072e1c0, {0xf819f8, 0xc000c20e80}, 0xc000754a90, 0xc000fb1300, {0xcebd60, 0xc000cd00c0})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:475 +0x6ba
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000130030, {0xf819f8, 0xc000c20e80}, 0xc000cb3310)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00009e500, {0xf81aa0, 0xc000d452f0}, 0xc000c93340)
    github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:603 +0x30e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xe11340, 0xc00009e500}, {0xf81aa0, 0xc000d452f0}, 0xc0005975c0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000236e00, {0xf8fd10, 0xc0004c4300}, 0xc0005b0100, 0xc00088ff20, 0x1516240, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc000236e00, {0xf8fd10, 0xc0004c4300}, 0xc0005b0100, 0x0)
    google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
    google.golang.org/grpc@v1.32.0/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.32.0/server.go:857 +0x294

Error: The terraform-provider-nutanix_v1.9.3 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

No changes / no crash

Actual Behavior

Wants to 'remove' the sysprep cdrom drive

Terraform will perform the following actions:

  # nutanix_virtual_machine.windows[0] will be updated in-place
  ~ resource "nutanix_virtual_machine" "windows" {
        id                                               = "blabla"
        name                                             = "windows1"
        # (35 unchanged attributes hidden)

      - disk_list {
          - data_source_reference  = {} -> null
          - disk_size_bytes        = 389120 -> null
          - disk_size_mib          = 1 -> null
          - uuid                   = "blabla" -> null
          - volume_group_reference = {} -> null

          - device_properties {
              - device_type  = "CDROM" -> null
              - disk_address = {
                  - "adapter_type" = "IDE"
                  - "device_index" = "0"
                } -> null
            }

          - storage_config {
              - storage_container_reference {
                  - kind = "storage_container" -> null
                  - name = "SelfServiceContainer" -> null
                  - uuid = "blabla" -> null
                }
            }
        }

        # (3 unchanged blocks hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. make vm with sysprep
  2. run apply twice
  3. always wants to remove cdrom, sometimes crashes (cannot repro reliably)

Important Factors

no

davhdavh commented 10 months ago

bug happens if one of the network requests get timeout (happened to be because the firewall would sometimes block the request to the cluster)