josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
538 stars 154 forks source link

terraform-provider-esxi_v1.10.2 - terrafom apply bug esxi 7.0 Update 3 panic: runtime error: invalid memory address or nil pointer dereference #186

Closed webdotwork closed 1 year ago

webdotwork commented 1 year ago

Hi there, i run two plugins installed locally on my machine for deploing VMs on esxi 7.0 Update 3 terraform-provider-esxi_v1.10.2 and terraform-provider-template everything went fine until a started to experiment with other versions of terraform i`ve changed tf versions with tfswitch several times and now a cant do terraform apply anymore terraform init and terraform plan goes great but terraform apply crushes with this error Error: Plugin did not respond

To Reproduce Steps to reproduce the behavior:

  1. tfswitch to version 0.12.31
  2. go back to old version that was 1.2.9
  3. Error: Plugin did not respond Stack trace from the terraform-provider-esxi_v1.10.2 plugin:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xdd6bec]

goroutine 90 [running]: github.com/josenk/terraform-provider-esxi/esxi.guestCREATE(0xc0006133b0, 0xc0006267a0, 0x13, 0xc000122640, 0xb, 0xc00018a320, 0x50, 0xc0001227a0, 0xf, 0xc0001226d8, ...) /home/www/go/src/github.com/josenk/terraform-provider-esxi/esxi/guest-create.go:212 +0x1f6c github.com/josenk/terraform-provider-esxi/esxi.resourceGUESTCreate(0xc0002fc930, 0xeee9a0, 0xc0006133b0, 0x2, 0x1a154a0) /home/www/go/src/github.com/josenk/terraform-provider-esxi/esxi/resource_guest.go:403 +0x1968 github.com/hashicorp/terraform/helper/schema.(Resource).Apply(0xc000124b00, 0xc000612a50, 0xc0004f8580, 0xeee9a0, 0xc0006133b0, 0xf00101, 0xc0004c4cc8, 0xc0004c1c80) /home/www/go/pkg/mod/github.com/hashicorp/terraform@v0.12.2/helper/schema/resource.go:286 +0x365 github.com/hashicorp/terraform/helper/schema.(Provider).Apply(0xc000124e00, 0xc00041b8d0, 0xc000612a50, 0xc0004f8580, 0xc0004c3dc8, 0xc000010278, 0xf022e0) /home/www/go/pkg/mod/github.com/hashicorp/terraform@v0.12.2/helper/schema/provider.go:285 +0x99 github.com/hashicorp/terraform/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc00011e4f0, 0x12aa3c0, 0xc0003af140, 0xc000304ae0, 0xc00011e4f0, 0xc0003af140, 0xc00051aa48) /home/www/go/pkg/mod/github.com/hashicorp/terraform@v0.12.2/helper/plugin/grpc_provider.go:851 +0x892 github.com/hashicorp/terraform/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1014d60, 0xc00011e4f0, 0x12aa3c0, 0xc0003af140, 0xc000612870, 0x0, 0x12aa3c0, 0xc0003af140, 0xc0004b0000, 0x3843) /home/www/go/pkg/mod/github.com/hashicorp/terraform@v0.12.2/internal/tfplugin5/tfplugin5.pb.go:3217 +0x217 google.golang.org/grpc.(Server).processUnaryRPC(0xc000001b00, 0x12b5920, 0xc0001f6480, 0xc0000e6800, 0xc000392c30, 0x19db200, 0x0, 0x0, 0x0) /home/www/go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:966 +0x46a google.golang.org/grpc.(Server).handleStream(0xc000001b00, 0x12b5920, 0xc0001f6480, 0xc0000e6800, 0x0) /home/www/go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:1245 +0xc9e google.golang.org/grpc.(Server).serveStreams.func1.1(0xc000036520, 0xc000001b00, 0x12b5920, 0xc0001f6480, 0xc0000e6800) /home/www/go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:685 +0xa1 created by google.golang.org/grpc.(*Server).serveStreams.func1 /home/www/go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:683 +0xa1

Error: The terraform-provider-esxi_v1.10.2 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 after tfswith back to previous version terraform apply runs normaly

Desktop (please complete the following information):

josenk commented 1 year ago

Try removing the terraform.tfstate files. You will loose your state, but I think it will clear things up. I highly recommend against using such an old version of Terraform. It's unsupported and things work very differently now.

webdotwork commented 1 year ago

Ive tried it already, removed all state files, changed tf version to other versions 1.2.9 1.3.0 1.3.1, rebuild the provider also try to get provider from source = "registry.terraform.io/josenk/esxi" but i still get this runtime error, think ive broke terraform on my host

webdotwork commented 1 year ago

Hi i figure out what was wrong, the problem was in cloud init image url, it was deprecated, think this issue can be closed, thx!