oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
758 stars 681 forks source link

crash when trying to update instance state since v6.12.0 #2205

Open newtoncorp opened 1 month ago

newtoncorp commented 1 month ago

Community Note

Terraform Version and Provider Version

terraform version ?? plugin version v6.12.0

Affected Resource(s)

oci_core_instance

Terraform Configuration Files

nil

Debug Output

nil

Panic Output

Error: Plugin did not respond

  with module.client.module.oci[0].oci_core_instance.this,
  on .terraform/modules/client.oci/main.tf line 1, in resource "oci_core_instance" "this":
   1: resource "oci_core_instance" "this" {

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-oci_v6.12.0 plugin:

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

goroutine 28 [running]:
github.com/oracle/terraform-provider-oci/internal/service/core.(*CoreInstanceResourceCrud).Update(0xc0032cedc0)
    github.com/oracle/terraform-provider-oci/internal/service/core/core_instance_resource.go:1511 +0x2119
github.com/oracle/terraform-provider-oci/internal/tfresource.UpdateResource({0x876d4b0, 0xc003002600}, {0x86ee240, 0xc0032cedc0})
    github.com/oracle/terraform-provider-oci/internal/tfresource/crud_helpers.go:359 +0x134
github.com/oracle/terraform-provider-oci/internal/service/core.updateCoreInstance(0xc003002600, {0x7dc27a0, 0xc002c54300})
    github.com/oracle/terraform-provider-oci/internal/service/core/core_instance_resource.go:1039 +0x2ed
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x875ef58?, {0x875ef58?, 0xc00314f7d0?}, 0xd?, {0x7dc27a0?, 0xc002c54300?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:800 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0022f8fc0, {0x875ef58, 0xc00314f7d0}, 0xc00347ca90, 0xc003002480, {0x7dc27a0, 0xc002c54300})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:919 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc002aeb3f8, {0x875ef58?, 0xc00314f710?}, 0xc002eecfa0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xd5c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc002aa40a0, {0x875ef58?, 0xc00314ed50?}, 0xc00313e3f0)
    github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/tf5server/server.go:846 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x7a586c0, 0xc002aa40a0}, {0x875ef58, 0xc00314ed50}, 0xc002b5f480, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00018ae00, {0x875ef58, 0xc00314ecc0}, {0x8773980, 0xc002b8b040}, 0xc0031585a0, 0xc002b9e930, 0xca7def8, 0x0)
    google.golang.org/grpc@v1.61.1/server.go:1385 +0xdd1
google.golang.org/grpc.(*Server).handleStream(0xc00018ae00, {0x8773980, 0xc002b8b040}, 0xc0031585a0)
    google.golang.org/grpc@v1.61.1/server.go:1796 +0xfb8
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.61.1/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 12
    google.golang.org/grpc@v1.61.1/server.go:1040 +0x125

Error: The terraform-provider-oci_v6.12.0 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

Should turn the instance off

Actual Behavior

crash

Steps to Reproduce

try to turn off / on an instance using oci_core_instance state

Important Factoids

is happening since latest release v6.12.0

References

drama17 commented 1 month ago

I've noticed it is probably related to the resources which should be changed (not to the new resources) and apply works from the 2nd/3rd try, when only the resources to be created left in output.

b-dean commented 1 month ago

I think this is just a bug in 6.12.0 where they added the security_attributes stuff. They try to cast it to map[string]map[string]interface{} but that's not how it's defined in the resource schema. I'm not sure exactly which security_attributes this is blowing up on, but they all just say map[string]interface{}

https://github.com/oracle/terraform-provider-oci/blob/master/internal/service/core/core_instance_resource.go#L261-L267 https://github.com/oracle/terraform-provider-oci/blob/master/internal/service/core/core_instance_resource.go#L692-L697

You'd be better off going back to v6.11.0 until this is fixed.

Also in v6.12.0 they vendored in a pre-release copy of oracle-go-sdk, instead of waiting for v65.75.1. This all seems like a botched rush-job.

twmcelroy commented 4 weeks ago

This bug has continued through 6.15.0. And more bugs have been filed like #2232 #2219 and #2210 . We have the same error when updated defined tags on an instance. 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] The plugin encountered an error, and failed to respond to the 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] more details. 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] Stack trace from the terraform-provider-oci_v6.13.0 plugin: 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] panic: interface conversion: interface {} is map[string]interface {}, not map[string]map[string]interface {} 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] 2024/10/16 12:25:14[TERRAFORM_CONSOLE] [INFO] goroutine 56 [running]:

Mainly commenting hoping oracle picks up on the bug since they have released multiple versions with it persisting.