Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash during 2nd run of windows with sysprep #638

Closed
davhdavh opened this issue Sep 20, 2023 · 1 comment
Closed

Crash during 2nd run of windows with sysprep #638

davhdavh opened this issue Sep 20, 2023 · 1 comment
Labels

Comments

@davhdavh
Copy link

Nutanix Cluster Information

Prism Element / AOS 6.5.1.6 LTS

Terraform Version

1.5.5

Affected Resource(s)

  • nutanix_virtual_machine

Terraform Configuration Files

resource "nutanix_virtual_machine" "windows" {
  count = 1 #length(local.hosts)
  name = "windows${count.index + 1}"
  cluster_uuid = local.cluster.metadata.uuid

  num_vcpus_per_socket = 1
  num_sockets          = local.hosts[count.index].num_cpu_sockets
  memory_size_mib      = 4096
  
  lifecycle {
    ignore_changes = [
      guest_customization_sysprep,
      disk_list.0.disk_size_bytes,
      disk_list.0.data_source_reference,
      disk_list.0.device_properties,
      disk_list.1.disk_size_bytes,
      disk_list.1.data_source_reference,
      disk_list.1.device_properties,
      disk_list.2.disk_size_bytes,
      disk_list.2.data_source_reference,
      disk_list.2.device_properties,
      disk_list.3.disk_size_bytes,
      disk_list.3.data_source_reference,
      disk_list.3.device_properties,
      owner_reference,
      project_reference,
    ]
  }

 disk_list {
   disk_size_mib   = 40000
   
   device_properties {
     device_type = "DISK"
     disk_address = {
       device_index = 0
       adapter_type = "SCSI"
     }
   }
 }

 disk_list {
   disk_size_bytes = 0

   data_source_reference = {
      kind = "image"
      uuid = data.nutanix_image.win_2019.id
   }
 
   device_properties {
     device_type = "CDROM"
     disk_address = {
       device_index = "0"
       adapter_type = "SATA"
     }
   }
 }

 boot_device_order_list = ["DISK", "CDROM"]

 boot_type = "UEFI"
 hardware_clock_timezone = "UTC"

 nic_list {
   subnet_uuid = data.nutanix_subnet.network.id
 }
  
  guest_customization_sysprep = {
    install_type = "FRESH"
    unattend_xml = base64encode(<<CLOUDINIT
blabla
CLOUDINIT
)
}

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/[email protected]/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/[email protected]/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/[email protected]/helper/schema/grpc_provider.go:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00009e500, {0xf81aa0, 0xc000d452f0}, 0xc000c93340)
	github.com/hashicorp/[email protected]/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/[email protected]/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/[email protected]/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc000236e00, {0xf8fd10, 0xc0004c4300}, 0xc0005b0100, 0x0)
	google.golang.org/[email protected]/server.go:1517 +0xa2a
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 +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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants