Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in resourceDigitalOceanAppRead #678

Closed
nightvisi0n opened this issue Aug 31, 2021 · 3 comments · Fixed by #684
Closed

Panic in resourceDigitalOceanAppRead #678

nightvisi0n opened this issue Aug 31, 2021 · 3 comments · Fixed by #684
Labels

Comments

@nightvisi0n
Copy link

@nightvisi0n nightvisi0n commented Aug 31, 2021

Bug Report

Today I tried to apply my terraform config, which ended in the following error:

Stack trace from the terraform-provider-digitalocean_v2.11.1 plugin:

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

goroutine 72 [running]:
github.com/digitalocean/terraform-provider-digitalocean/digitalocean.resourceDigitalOceanAppRead(0x123ae98, 0xc0000ad620, 0xc00052a000, 0xf60860, 0xc0005af740, 0xc000437920, 0xc00062b908, 0x40e0f8)
        github.com/digitalocean/terraform-provider-digitalocean/digitalocean/resource_digitalocean_app.go:111 +0x471
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0001888c0, 0x123ae28, 0xc0003c7700, 0xc00052a000, 0xf60860, 0xc0005af740, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:347 +0x17f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0001888c0, 0x123ae28, 0xc0003c7700, 0xc0003ac7e0, 0xf60860, 0xc0005af740, 0xc0004967a0, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:624 +0x1cb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0000b0090, 0x123ae28, 0xc0003c7700, 0xc0003c7740, 0xc0003c7700, 0x40b965, 0x1007960)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:575 +0x43b
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc0000ba380, 0x123aed0, 0xc0003c7700, 0xc0008923c0, 0xc0000ba380, 0xc000739620, 0xc000815ba0)
        github.com/hashicorp/[email protected]/tfprotov5/server/server.go:298 +0x105
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x1049820, 0xc0000ba380, 0x123aed0, 0xc000739620, 0xc000892360, 0x0, 0x123aed0, 0xc000739620, 0xc00042ec00, 0x1065)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000d6540, 0x1244738, 0xc000642f00, 0xc000820000, 0xc0005ae120, 0x17d8b90, 0x0, 0x0, 0x0)
        google.golang.org/[email protected]/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0000d6540, 0x1244738, 0xc000642f00, 0xc000820000, 0x0)
        google.golang.org/[email protected]/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0000b61c0, 0xc0000d6540, 0x1244738, 0xc000642f00, 0xc000820000)
        google.golang.org/[email protected]/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:857 +0x1fd

Error: The terraform-provider-digitalocean_v2.11.1 plugin crashed!

It seems this bug occurs in any operation where the current state from the DO App Platform has to be read.

The terraform config uses the following resources:

  • digitalocean_database_cluster
  • digitalocean_database_db
  • digitalocean_database_user
  • digitalocean_app

If you need any more info please let me know.

@nightvisi0n nightvisi0n changed the title Panic during terraform apply Panic in resourceDigitalOceanAppRead Aug 31, 2021
@danaelhe
Copy link
Contributor

@danaelhe danaelhe commented Aug 31, 2021

Hi there,

Would it be possible to include your terraform config file? Has this config file always been erroring out or has it ever been successful?

Thanks!

@nightvisi0n
Copy link
Author

@nightvisi0n nightvisi0n commented Sep 2, 2021

Hi, after further investigation it seems like this only happens if the initial deployment fails (e.g. due to a missing image in DOCR).
The same config worked after a manual (successful) deployment.
I think this bug is reproducible by deploying a minimal app with a non-existent DOCR image (which will fail).

@andrewsomething
Copy link
Member

@andrewsomething andrewsomething commented Sep 2, 2021

Thanks for the follow up @nightvisi0n. This is clearly an error state. We should be checking for the active deployment here and erroring out if it does not exist before trying to access its ID rather than panicking.

d.Set("active_deployment_id", app.ActiveDeployment.ID)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants