IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
340 stars 667 forks source link

Provider crash when setting IAM account settings #5351

Open ocofaigh opened 4 months ago

ocofaigh commented 4 months ago

When trying to execute the module https://github.com/terraform-ibm-modules/terraform-ibm-iam-account-settings/blob/main/main.tf we saw the provider crash....

Community Note

Terraform CLI and Terraform IBM Provider Version

tf 1.5.7 ibm provider 1.56.1

Affected Resource(s)

Terraform Configuration Files

See https://github.com/terraform-ibm-modules/terraform-ibm-iam-account-settings/blob/main/main.tf

Debug Output

│ Error: Request cancelled
│ 
│   with module.iam_account_settings.module.iam_account_settings.ibm_iam_account_settings.iam_account_settings,
│   on .terraform/modules/iam_account_settings.iam_account_settings/main.tf line 18, in resource "ibm_iam_account_settings" "iam_account_settings":
│   18: resource "ibm_iam_account_settings" "iam_account_settings" {
│ 
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵
╷
│ Error: Plugin did not respond
│ 
│   with module.iam_account_settings.module.iam_account_settings.ibm_cloud_shell_account_settings.cloud_shell_account_settings,
│   on .terraform/modules/iam_account_settings.iam_account_settings/main.tf line 39, in resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings":
│   39: resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings" {
│ 
│ 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-ibm_v1.56.1 plugin:

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

goroutine 125 [running]:
[github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell.resourceIBMCloudShellAccountSettingsCreate](http://github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell.resourceIBMCloudShellAccountSettingsCreate)({0x4ae40b8, 0xc000724ba0}, 0x0?, {0x4233b00?, 0xc001e42000})
    [github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell/resource_ibm_cloud_shell_account_settings.go:172](http://github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell/resource_ibm_cloud_shell_account_settings.go:172) +0x6b4
[github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create](http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create)(0xc000e63880, {0x4ae40f0, 0xc00128d5f0}, 0xd?, {0x4233b00, 0xc001e42000})
    [github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/resource.go:707](http://github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/resource.go:707) +0x12e
[github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply](http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply)(0xc000e63880, {0x4ae40f0, 0xc00128d5f0}, 0xc000ddd380, 0xc0006c8780, {0x4233b00, 0xc001e42000})
    [github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/resource.go:837](http://github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/resource.go:837) +0xa7a
[github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange](http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange)(0xc0006d92f0, {0x4ae40f0?, 0xc00128d4d0?}, 0xc00152b6d0)
    [github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/grpc_provider.go:1021](http://github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.0/helper/schema/grpc_provider.go:1021) +0xe3c
[github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange](http://github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange)(0xc000104780, {0x4ae40f0?, 0xc00128ccc0?}, 0xc0003d8a10)
    [github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:818](http://github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:818) +0x574
[github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler](http://github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler)({0x40a1ea0?, 0xc000104780}, {0x4ae40f0, 0xc00128ccc0}, 0xc0003d8930, 0x0)
    [github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385](http://github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385) +0x170
[google.golang.org/grpc.(*Server).processUnaryRPC](http://google.golang.org/grpc.(*Server).processUnaryRPC)(0xc0005b05a0, {0x4aebe20, 0xc0011c6000}, 0xc0012918c0, 0xc001159590, 0x681bd20, 0x0)
    [google.golang.org/grpc@v1.53.0/server.go:1336](http://google.golang.org/grpc@v1.53.0/server.go:1336) +0xd13
[google.golang.org/grpc.(*Server).handleStream](http://google.golang.org/grpc.(*Server).handleStream)(0xc0005b05a0, {0x4aebe20, 0xc0011c6000}, 0xc0012918c0, 0x0)
    [google.golang.org/grpc@v1.53.0/server.go:1704](http://google.golang.org/grpc@v1.53.0/server.go:1704) +0xa1b
[google.golang.org/grpc.(*Server).serveStreams.func1.2()](http://google.golang.org/grpc.(*Server).serveStreams.func1.2())
    [google.golang.org/grpc@v1.53.0/server.go:965](http://google.golang.org/grpc@v1.53.0/server.go:965) +0x98
created by [google.golang.org/grpc.(*Server).serveStreams.func1](http://google.golang.org/grpc.(*Server).serveStreams.func1)
    [google.golang.org/grpc@v1.53.0/server.go:963](http://google.golang.org/grpc@v1.53.0/server.go:963) +0x28a

Error: The terraform-provider-ibm_v1.56.1 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.

Panic Output

iam-account-settings-module-test-logs-240514-050649.tar.gz

Expected Behavior

Actual Behavior

Steps to Reproduce

  1. terraform apply

Important Factoids

References

ocofaigh commented 4 months ago

cc @hkantare

pauljegouic commented 4 months ago

Got the same on other resource @ocofaigh see #5349

pauljegouic commented 4 months ago

1.66.0-beta0 fix the issue, could you confirm ?

May I get a release date of the 1.66, I got some milestones next week.

hkantare commented 4 months ago

@pauljegouic We have https://github.com/IBM-Cloud/terraform-provider-ibm/releases/tag/v1.65.1 with the fix for above issue Can this release help you out

pauljegouic commented 4 months ago

Not sure about your fix :

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ibm_cloud_shell_account_settings.cloud_shell_account_settings: Destroying... [id=ac-3f2cae45b0644f6d87aefcf404f5987f]
ibm_cloud_shell_account_settings.cloud_shell_account_settings: Destruction complete after 0s
ibm_cloud_shell_account_settings.cloud_shell_account_settings: Creating...
ibm_cloud_shell_account_settings.cloud_shell_account_settings: Still creating... [10s elapsed]
ibm_cloud_shell_account_settings.cloud_shell_account_settings: Still creating... [20s elapsed]
╷
│ Error: Plugin did not respond
│ 
│   with ibm_cloud_shell_account_settings.cloud_shell_account_settings,
│   on main.tf line 9, in resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings":
│    9: resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings" {
│ 
│ 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-ibm_v1.65.1 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1026fb1e8]

goroutine 125 [running]:
github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell.resourceIBMCloudShellAccountSettingsCreate({0x105489078, 0x1400290f080}, 0x1074c0d20?, {0x10542f560?, 0x14000b0d500})
        github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell/resource_ibm_cloud_shell_account_settings.go:172 +0x5e8
github.com/IBM-Cloud/terraform-provider-ibm/ibm/provider.wrapFunction.func1({0x105489078?, 0x1400290f080?}, 0x0?, {0x10542f560?, 0x14000b0d500?})
        github.com/IBM-Cloud/terraform-provider-ibm/ibm/provider/provider.go:1533 +0x34
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1400164b420, {0x1054890b0, 0x14001ff2030}, 0xd?, {0x10542f560, 0x14000b0d500})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:778 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x1400164b420, {0x1054890b0, 0x14001ff2030}, 0x14001b1e5b0, 0x140029d2680, {0x10542f560, 0x14000b0d500})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x890
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140001678a8, {0x1054890b0?, 0x140029d1ef0?}, 0x140029b05f0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb70
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14000a60280, {0x1054890b0?, 0x140029d16e0?}, 0x140028bcee0)
        github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x3b8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1052a8800?, 0x14000a60280}, {0x1054890b0, 0x140029d16e0}, 0x140028bce70, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400012e000, {0x105493e20, 0x14000b921a0}, 0x140029a4900, 0x140015f56b0, 0x10747fd98, 0x0)
        google.golang.org/grpc@v1.57.1/server.go:1358 +0xc88
google.golang.org/grpc.(*Server).handleStream(0x1400012e000, {0x105493e20, 0x14000b921a0}, 0x140029a4900, 0x0)
        google.golang.org/grpc@v1.57.1/server.go:1735 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.57.1/server.go:970 +0xb4
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.57.1/server.go:981 +0x174

Error: The terraform-provider-ibm_v1.65.1 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.

@hkantare

pauljegouic commented 4 months ago

definitely not fixing.

➜  test git:(feat/init) ✗ terraform apply --auto-approve  
data.ibm_iam_account_settings.iam_account_settings: Reading...
data.ibm_iam_account_settings.iam_account_settings: Read complete after 0s [id=3f2cae45b0644f6d87aefcf404f5987f]
data.ibm_cloud_shell_account_settings.cloud_shell_account_settings: Reading...
data.ibm_cloud_shell_account_settings.cloud_shell_account_settings: Read complete after 2s

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # ibm_cloud_shell_account_settings.cloud_shell_account_settings will be created
  + resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings" {
      + account_id = "3f2cae45b0644f6d87aefcf404f5987f"
      + created_at = (known after apply)
      + created_by = (known after apply)
      + enabled    = false
      + id         = (known after apply)
      + rev        = (known after apply)
      + type       = (known after apply)
      + updated_at = (known after apply)
      + updated_by = (known after apply)

      + features {
          + enabled = (known after apply)
          + key     = (known after apply)
        }

      + regions {
          + enabled = (known after apply)
          + key     = (known after apply)
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
ibm_cloud_shell_account_settings.cloud_shell_account_settings: Creating...
╷
│ Error: Plugin did not respond
│ 
│   with ibm_cloud_shell_account_settings.cloud_shell_account_settings,
│   on main.tf line 9, in resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings":
│    9: resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings" {
│ 
│ 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-ibm_v1.65.1 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1024ff1e8]

goroutine 119 [running]:
github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell.resourceIBMCloudShellAccountSettingsCreate({0x10528d078, 0x1400299d260}, 0x1072c4d20?, {0x105233560?, 0x14000a60a80})
        github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/cloudshell/resource_ibm_cloud_shell_account_settings.go:172 +0x5e8
github.com/IBM-Cloud/terraform-provider-ibm/ibm/provider.wrapFunction.func1({0x10528d078?, 0x1400299d260?}, 0x0?, {0x105233560?, 0x14000a60a80?})
        github.com/IBM-Cloud/terraform-provider-ibm/ibm/provider/provider.go:1533 +0x34
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x140015a2e00, {0x10528d0b0, 0x140029c95f0}, 0xd?, {0x105233560, 0x14000a60a80})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:778 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140015a2e00, {0x10528d0b0, 0x140029c95f0}, 0x140029bd860, 0x14001bebc00, {0x105233560, 0x14000a60a80})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0x890
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140011b1458, {0x10528d0b0?, 0x140029c94d0?}, 0x14001be5bd0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xb70
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14000ade640, {0x10528d0b0?, 0x140029c8ae0?}, 0x1400298d650)
        github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x3b8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1050ac800?, 0x14000ade640}, {0x10528d0b0, 0x140029c8ae0}, 0x1400298d5e0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140001c0000, {0x105297e20, 0x1400021a680}, 0x140029c5200, 0x140015696e0, 0x107283d98, 0x0)
        google.golang.org/grpc@v1.57.1/server.go:1358 +0xc88
google.golang.org/grpc.(*Server).handleStream(0x140001c0000, {0x105297e20, 0x1400021a680}, 0x140029c5200, 0x0)
        google.golang.org/grpc@v1.57.1/server.go:1735 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.57.1/server.go:970 +0xb4
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.57.1/server.go:981 +0x174

Error: The terraform-provider-ibm_v1.65.1 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.
pauljegouic commented 4 months ago

To reproduce, simply apply the following terraform:

provider "ibm" {
  region           = "eu-fr2"
  ibmcloud_timeout = 60
}

terraform {
  required_version = "> 1.0.0, < 1.6.0"
  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      version = ">= 1.56.1, < 2.0.0"
    }
  }
}

data "ibm_iam_account_settings" "iam_account_settings" {
}

data "ibm_cloud_shell_account_settings" "cloud_shell_account_settings" {
  account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
}

resource "ibm_cloud_shell_account_settings" "cloud_shell_account_settings" {
  rev        = data.ibm_cloud_shell_account_settings.cloud_shell_account_settings.rev
  account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
  enabled    = false
}
hkantare commented 4 months ago

The backend team is still investigating the issue

pauljegouic commented 4 months ago

any update @hkantare this is becoming a big issue on my side, since it creates us a lot of technical debt (workaround everywhere)

hkantare commented 4 months ago

@pauljegouic I'm following up with Cloud shell team. I will provide updates shortly

tonymcguckin commented 4 months ago

Thanks @pauljegouic @ocofaigh for your patience guys as a fix was developed. Please test on production and let me know how you get on and if you require anything further in this area. Thank you @hkantare for your help here also, much appreciated.

pauljegouic commented 4 months ago

I confirm on my side. Thanks guys !