Skip to content

user_data typos cause panic, ForceNew for guest_customization fields #67

Closed
@rxacevedo

Description

Describe the bug

There are some typos in resource_nutanix_virtual_machine.go that cause the provider to panic when a user_data change is made and applied. Another issue though, is that the API seems to reject user_data updates to existing VMs (which makes sense, since user_data is a run-once deal). However, in the provider, this is communicated to the user as a change (~).

Expected behavior

I believe the provider should calculate a destroy/create operation (-/+) to better mirror other providers that operate against cloud providers/enforce immutable infrastructure, when changes to user_data/cloud-config/sysprep are made.

Logs

Panic:

panic: interface conversion: interface {} is nil, not string
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix:
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: goroutine 58 [running]:
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: github.com/terraform-providers/terraform-provider-nutanix/nutanix.resourceNutanixVirtualMachineUpdate(0xc0003317a0, 0xdb2d20, 0xc000567350, 0x24, 0x19ad460)
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/home/roberto/go/src/github.com/terraform-providers/terraform-provider-nutanix/nutanix/resource_nutanix_virtual_machine.go:1114 +0x4744
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: github.com/terraform-providers/terraform-provider-nutanix/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0001a3110, 0xc000395860, 0xc000667740, 0xdb2d20, 0xc000567350, 0xcc1901, 0xc000962ba0, 0x0)
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/home/roberto/go/src/github.com/terraform-providers/terraform-provider-nutanix/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:231 +0x252
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: github.com/terraform-providers/terraform-provider-nutanix/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc0002c05b0, 0xc000395810, 0xc000395860, 0xc000667740, 0xc000347530, 0xc000636d20, 0x18)
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/home/roberto/go/src/github.com/terraform-providers/terraform-provider-nutanix/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:283 +0x18f
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: github.com/terraform-providers/terraform-provider-nutanix/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc0005d26a0, 0xc0006670a0, 0xc0002ac450, 0x0, 0x0)
2019-06-25T10:43:32.412-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/home/roberto/go/src/github.com/terraform-providers/terraform-provider-nutanix/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:527 +0x57
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: reflect.Value.call(0xc00012f1a0, 0xc000397160, 0x13, 0xf67d99, 0x4, 0xc00007ef18, 0x3, 0x3, 0xc00037e380, 0xc0003f2c68, ...)
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/usr/lib/go/src/reflect/value.go:447 +0x461
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: reflect.Value.Call(0xc00012f1a0, 0xc000397160, 0x13, 0xc000369718, 0x3, 0x3, 0xc0003f2c40, 0xc000369710, 0xc0003697b8)
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/usr/lib/go/src/reflect/value.go:308 +0xa4
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: net/rpc.(*service).call(0xc00044f400, 0xc00015b7c0, 0xc0004afd20, 0xc0004afd30, 0xc00039eb00, 0xc0005d2be0, 0xdb7260, 0xc0006670a0, 0x16, 0xdb72a0, ...)
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/usr/lib/go/src/net/rpc/server.go:384 +0x14e
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: created by net/rpc.(*Server).ServeCodec
2019-06-25T10:43:32.413-0400 [DEBUG] plugin.terraform-provider-nutanix: 	/usr/lib/go/src/net/rpc/server.go:481 +0x42b
2019/06/25 10:43:32 [TRACE] root: eval: *terraform.EvalWriteState
2019/06/25 10:43:32 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2019/06/25 10:43:32 [TRACE] root: eval: *terraform.EvalIf
2019/06/25 10:43:32 [TRACE] root: eval: *terraform.EvalWriteState
2019/06/25 10:43:32 [TRACE] root: eval: *terraform.EvalWriteDiff
2019/06/25 10:43:32 [TRACE] root: eval: *terraform.EvalApplyPost
2019-06-25T10:43:32.416-0400 [DEBUG] plugin: plugin process exited: path=/home/roberto/.terraform.d/plugins/terraform-provider-nutanix
2019/06/25 10:43:32 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error occurred:
	* nutanix_virtual_machine.node: unexpected EOF

2019/06/25 10:43:32 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error occurred:
	* nutanix_virtual_machine.node: unexpected EOF

2019/06/25 10:43:32 [TRACE] [walkApply] Exiting eval tree: nutanix_virtual_machine.node
2019/06/25 10:43:32 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2019/06/25 10:43:32 [TRACE] dag/walk: upstream errored, not walking "provider.nutanix (close)"
2019/06/25 10:43:32 [TRACE] dag/walk: upstream errored, not walking "root"
2019/06/25 10:43:32 [TRACE] Preserving existing state lineage "d72dbd27-0147-3a5a-7f88-e08af0110ffb"
2019/06/25 10:43:32 [TRACE] Preserving existing state lineage "d72dbd27-0147-3a5a-7f88-e08af0110ffb"
2019/06/25 10:43:32 [TRACE] Preserving existing state lineage "d72dbd27-0147-3a5a-7f88-e08af0110ffb"
2019/06/25 10:43:32 [TRACE] Preserving existing state lineage "d72dbd27-0147-3a5a-7f88-e08af0110ffb"
2019/06/25 10:43:32 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-06-25T10:43:32.448-0400 [WARN ] plugin: error closing client during Kill: err="connection is shut down"
2019-06-25T10:43:32.449-0400 [DEBUG] plugin.terraform-provider-http_v1.1.1_x4: 2019/06/25 10:43:32 [ERR] plugin: plugin server: accept unix /tmp/plugin507544391: use of closed network connection
2019-06-25T10:43:32.449-0400 [DEBUG] plugin.terraform-provider-template_v2.1.2_x4: 2019/06/25 10:43:32 [ERR] plugin: plugin server: accept unix /tmp/plugin080363620: use of closed network connection
2019-06-25T10:43:32.450-0400 [DEBUG] plugin: plugin process exited: path=/home/roberto/code/seibels/infrastructure/terraform/nutanix/sbx/test/.terraform/plugins/linux_amd64/terraform-provider-template_v2.1.2_x4
2019-06-25T10:43:32.452-0400 [DEBUG] plugin: plugin process exited: path=/home/roberto/code/seibels/infrastructure/terraform/nutanix/sbx/test/.terraform/plugins/linux_amd64/terraform-provider-http_v1.1.1_x4



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

After correcting typos so that schema.ResourceData.GetChange does not return nil/panic on type assertion, API clearly indicates that this operation is not allowed, thus the provider should make this more obvious to the user and trigger a destroy/create operation.

Error: Error applying plan:

1 error occurred:
	* nutanix_virtual_machine.node: 1 error occurred:
	* nutanix_virtual_machine.node: error updating Virtual Machine UUID(f7bfee26-4196-4be1-8101-eb267769482f): error: {
  "api_version": "3.1",
  "code": 422,
  "message_list": [
    {
      "message": "The VM guest customization configuration  cannot be changed after VM creation.",
      "reason": "INVALID_REQUEST"
    }
  ],
  "state": "ERROR"
}

Versions (please complete the following information):

  • linux_amd64
  • Terraform v0.11.14
  • Nutanix Cluster (Prism Element / AOS) Version 5.10.3.2 LTS
  • Nutanix Prism Central Version 5.10.3
  • Terraform provider version (compiled locally off of master / 5fd531b)

Additional context
I had to compile this myself off of master / 5fd531b in order to get past this issue:

Error: Error applying plan:

1 error occurred:
	* nutanix_virtual_machine.node: 1 error occurred:
	* nutanix_virtual_machine.node: internal error: cannot shut down the VM with UUID(f7bfee26-4196-4be1-8101-eb267769482f): error updating Virtual Machine UUID(f7bfee26-4196-4be1-8101-eb267769482f): error: {
  "api_version": "3.1",
  "code": 422,
  "message_list": [
    {
      "message": "Must specify NIC is_connected during update.",
      "reason": "INVALID_REQUEST"
    }
  ],
  "state": "ERROR"
}

Which is thrown when updating user_data using 1.0.1 (pulled from the provider registry via terraform init)

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions