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

Terraform provider crashes when using guest_customization_sysprep_custom_key_values #441

Closed
d4vydm opened this issue May 5, 2022 · 3 comments
Assignees
Labels

Comments

@d4vydm
Copy link

d4vydm commented May 5, 2022

Nutanix Cluster Information

Nutanix cluster: fraser-6.1-stable
Nutanix Prism central: 6.1

Terraform Version

Terraform v1.1.9
on darwin_arm64

provider registry.terraform.io/nutanix/nutanix v1.4.1

Affected Resource(s)

/

Terraform Configuration Files

This part of the TF config file is relevant:

...
resource "nutanix_virtual_machine" "vm" {
    name                 = "${var.machine["vm_name"]}"
    num_vcpus_per_socket = var.machine["vm_num_vcpus_per_socket"]
    num_sockets          = var.machine["vm_cpu"]
    memory_size_mib      = var.machine["vm_ram_mb"]
    cluster_uuid         = var.nutanix_cluster.id
    
    guest_customization_sysprep = {
      install_type = "PREPARED"
      unattend_xml = base64encode(file("${path.module}/files/unattend.xml"))
    }
    guest_customization_sysprep_custom_key_values = {
      vm_hostname = "TEST123"
    }
...

Debug Output

/

Panic Output

│ Error: Plugin did not respond

...

Stack trace from the terraform-provider-nutanix_v1.4.1 plugin:

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

goroutine 66 [running]:
github.com/terraform-providers/terraform-provider-nutanix/nutanix.getVMResources(0x14000124600, 0x140002c8000)
        github.com/terraform-providers/terraform-provider-nutanix/nutanix/resource_nutanix_virtual_machine.go:1565 +0x1740
github.com/terraform-providers/terraform-provider-nutanix/nutanix.resourceNutanixVirtualMachineCreate({0x100e0ff88, 0x1400092ab40}, 0x14000124600, {0x100cba460, 0x140003f28a0})
        github.com/terraform-providers/terraform-provider-nutanix/nutanix/resource_nutanix_virtual_machine.go:670 +0x4a8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x14000223340, {0x100e0ff18, 0x140005989c0}, 0x14000124600, {0x100cba460, 0x140003f28a0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:341 +0x118
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000223340, {0x100e0ff18, 0x140005989c0}, 0x140007c0340, 0x14000302600, {0x100cba460, 0x140003f28a0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:467 +0x8d8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140000b2018, {0x100e0ff18, 0x140005989c0}, 0x1400091ab90)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:977 +0xe38
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14000592800, {0x100e0ffc0, 0x140005dcc30}, 0x140008084d0)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:603 +0x338
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x100dc5700, 0x14000592800}, {0x100e0ffc0, 0x140005dcc30}, 0x140006c4600, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x140001bce00, {0x100e1c590, 0x14000414300}, 0x140007dc200, 0x140003ed080, 0x10130ff80, 0x0)
        google.golang.org/[email protected]/server.go:1194 +0xc38
google.golang.org/grpc.(*Server).handleStream(0x140001bce00, {0x100e1c590, 0x14000414300}, 0x140007dc200, 0x0)
        google.golang.org/[email protected]/server.go:1517 +0xa34
google.golang.org/grpc.(*Server).serveStreams.func1.2(0x140000a0d60, 0x140001bce00, {0x100e1c590, 0x14000414300}, 0x140007dc200)
        google.golang.org/[email protected]/server.go:859 +0x94
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:857 +0x1f0

Error: The terraform-provider-nutanix_v1.4.1 plugin crashed!

Expected Behavior

/

Actual Behavior

/

Steps to Reproduce

  1. terraform apply

References

/

@d4vydm
Copy link
Author

d4vydm commented May 5, 2022

Initial analysis

I believe the crash seems to be related to type assertion from interface{} to map[string]string while underlaying type is map[string]interface{}.

Error line:
https://github.com/nutanix/terraform-provider-nutanix/blob/e9691c624b90c1ab030d4c8cb62bc14e0d4ac9a9/nutanix/resource_nutanix_virtual_machine.go#L1565

v is of type interface{} but has an underlaying value of type map[string]interface{}. The type assertion assumes it is map[string]string.

@abhimutant abhimutant self-assigned this Jul 18, 2022
@abhimutant abhimutant added 1.7 and removed 1.6.0 labels Jul 18, 2022
@abhimutant
Copy link
Collaborator

Tracking #478

@DevTown
Copy link

DevTown commented Apr 5, 2023

How is the correct way to use the example?

` guest_customization_sysprep = {
install_type = "PREPARED"
unattend_xml = base64encode(file("unattend.xml"))
}
guest_customization_sysprep_custom_key_values = {

			VMNAME = "${format("vdi-%03d", count.index + 1)}"
		}`

I am trying but when i use it like this i get the error when i hit apply:

Error: error: { │ "api_version": "3.1", │ "code": 422, │ "message_list": [ │ { │ "details": { │ "spec.resources.guest_customization.sysprep": [ │ "{u'install_type': u'PREPARED', u'unattend_xml': u'BASE64STRING_OF_unattend.xml', u'custom_key_values': {u'VMNAME': u'vdi-tc10f-T-001'}} is valid under each of {'required': ['custom_key_values']}, {'required': ['unattend_xml']}" │ ] │ }, │ "message": "Request could not be processed.", │ "reason": "INVALID_REQUEST" │ } │ ], │ "state": "ERROR" │ }

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

4 participants