SAP / terraform-provider-btp

Terraform provider for SAP BTP
https://registry.terraform.io/providers/SAP/btp/latest
Apache License 2.0
89 stars 18 forks source link

[BUG] Terraform scripts crashed during long running subscription #916

Closed wope4455 closed 1 month ago

wope4455 commented 1 month ago

Is there an existing issue for this?

What version of the Terraform provider are you using?

1.7.0

What version of the Terraform CLI are you using?

1.9.2

What type of issue are you facing

bug report

Describe the bug

Terraform script crashed during a long running service subscription exactly after 10 minutes. At the subaccount the subscription process finished well after some additional time and the service is running. I faced this issue 2 times

Expected Behavior

No response

Steps To Reproduce

Long running subscription of a service like SAP Build ProcessAutomation

User's Role Collections

No response

Add screenshots to help explain your problem

No response

Additional context

btp_subaccount_subscription.sap_build_process: Still creating... [10m0s elapsed]
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵

Stack trace from the terraform-provider-btp_v1.7.0 plugin:

panic: interface conversion: interface {} is nil, not saas_manager_service.EntitledApplicationsResponseObject

goroutine 60 [running]:
github.com/SAP/terraform-provider-btp/internal/provider.(*subaccountSubscriptionResource).Create(0x1400038c030, {0x1038da348, 0x14000429290}, {{{{0x1038df6b0, 0x1400030d560}, {0x1037a7400, 0x1400030d230}}, {0x1038e2d98, 0x1400016d090}}, {{{0x1038df6b0, ...}, ...}, ...}, ...}, ...)
        github.com/SAP/terraform-provider-btp/internal/provider/resource_subaccount_subscription.go:251 +0x72c
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0x140002061e0, {0x1038da348, 0x14000429290}, 0x140000c5528, 0x140000c5500)
        github.com/hashicorp/terraform-plugin-framework@v1.12.0/internal/fwserver/server_createresource.go:101 +0x400
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0x140002061e0, {0x1038da348, 0x14000429290}, 0x1400009c370, 0x140000c5620)
        github.com/hashicorp/terraform-plugin-framework@v1.12.0/internal/fwserver/server_applyresourcechange.go:57 +0x380
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0x140002061e0, {0x1038da348?, 0x140004291a0?}, 0x1400009c190)
        github.com/hashicorp/terraform-plugin-framework@v1.12.0/internal/proto6server/server_applyresourcechange.go:55 +0x2e0
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x14000210a00, {0x1038da348?, 0x140004282a0?}, 0x140001f6070)
        github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/tf6server/server.go:865 +0x2a8
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1038a3b60, 0x14000210a00}, {0x1038da348, 0x140004282a0}, 0x14000426000, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:545 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000196e00, {0x1038da348, 0x140004281e0}, {0x1038e15a0, 0x140003f2000}, 0x140003f8000, 0x1400030c0c0, 0x103e61918, 0x0)
        google.golang.org/grpc@v1.66.2/server.go:1394 +0xb64
google.golang.org/grpc.(*Server).handleStream(0x14000196e00, {0x1038e15a0, 0x140003f2000}, 0x140003f8000)
        google.golang.org/grpc@v1.66.2/server.go:1805 +0xb20
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.66.2/server.go:1029 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 52
        google.golang.org/grpc@v1.66.2/server.go:1040 +0x13c

Error: The terraform-provider-btp_v1.7.0 plugin crashed!
lechnerc77 commented 1 month ago

@wope4455 Did you specify a timeout block when defining the resource?

The default timeout for subscriptions is 10 minutes, but you can adjust them via the timeout block (see https://registry.terraform.io/providers/SAP/btp/latest/docs/resources/subaccount_subscription#timeouts)

wope4455 commented 1 month ago

@wope4455 Did you specify a timeout block when defining the resource?

The default timeout for subscriptions is 10 minutes, but you can adjust them via the timeout block (see https://registry.terraform.io/providers/SAP/btp/latest/docs/resources/subaccount_subscription#timeouts)

@lechnerc77 : thanks for the hint - I haven't used this timeout block - but I would expect that the script would generate a message when reaching that point and does not crash.

lechnerc77 commented 1 month ago

@wope4455 The handling of the retry block is part of the Terraform Framework, so we have only limited influence on the abort that happens in your case. But we will evaluate if we can influence the behavior on a lower execution level (namely in our client) to exit more gracefully