microsoft / terraform-provider-azuredevops

Terraform Azure DevOps provider
https://www.terraform.io/docs/providers/azuredevops/
MIT License
379 stars 271 forks source link

Provider crash reading deleted group #932

Open iam-take opened 10 months ago

iam-take commented 10 months ago

We created a Azure DevOps group via Terraform, creation went fine but we removed it manually from the portal. When rerunning the code the provider will crash.

A similar issue was also reported by @FRUCHTiii I have the feeling more resources could be effected with the same issue.

Removing the resources from the state file with terraform state rm will resolve the issue so you can redeploy them.

Community Note

Terraform (and Azure DevOps Provider) Version

Terraform Version 1.5.7 Provider version 0.10.0

Affected Resource(s)

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

Panic Output

Stack trace from the terraform-provider-azuredevops_v0.10.0 plugin:

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

goroutine 46 [running]:
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/memberentitlementmanagement.flattenGroupEntitlement(0xc0002ba5c0?, 0xc0005c04c0)
    github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/memberentitlementmanagement/resource_group_entitlement.go:269 +0x29
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/memberentitlementmanagement.resourceGroupEntitlementRead(0xc00069b380, {0xcd0440?, 0xc0003b26e0})
    github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/memberentitlementmanagement/resource_group_entitlement.go:157 +0x2b4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xfcbbc0?, {0xfcbbc0?, 0xc00070b3b0?}, 0xd?, {0xcd0440?, 0xc0003b26e0?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.23.0/helper/schema/resource.go:712 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000402d20, {0xfcbbc0, 0xc00070b3b0}, 0xc0002eeb60, {0xcd0440, 0xc0003b26e0})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.23.0/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000119368, {0xfcbbc0?, 0xc00070b290?}, 0xc0002bb200)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.23.0/helper/schema/grpc_provider.go:613 +0x497
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc00036aaa0, {0xfcbbc0?, 0xc00070aab0?}, 0xc0000c2e40)
    github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:748 +0x49e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xe313e0?, 0xc00036aaa0}, {0xfcbbc0, 0xc00070aab0}, 0xc00072a1c0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003c0000, {0xfce8c0, 0xc0002c24e0}, 0xc0006b1d40, 0xc0004321b0, 0x15078f0, 0x0)
    google.golang.org/grpc@v1.56.3/server.go:1335 +0xde3
google.golang.org/grpc.(*Server).handleStream(0xc0003c0000, {0xfce8c0, 0xc0002c24e0}, 0xc0006b1d40, 0x0)
    google.golang.org/grpc@v1.56.3/server.go:1712 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.56.3/server.go:947 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.56.3/server.go:958 +0x15c

Error: The terraform-provider-azuredevops_v0.10.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

The provider should have seen the group has been removed and recreate it.

Actual Behavior

Provider crashes

Steps to Reproduce

  1. terraform apply
  2. Manually remove the group in the portal / powershell / api
  3. rerun terraform plan / apply

Important Factoids

References

eokorieFA commented 9 months ago

I am having similar problems. I pretty much did the same thing as the above. Manually deleted a resource group through the Azure Portal. Re-running the pipeline, I am getting the same error as above.

ncook-hxgn commented 9 months ago

+1

michael-leon commented 9 months ago

We are running into this issue as well. It's happening reading azuredevops_project too. Interestingly it works on a different workspace.

robdock92 commented 6 months ago

I can confirm that the issue is still present in 0.11.0 and that the provided workaround is successful for the issue with group entitlement.

owaisrehman commented 1 month ago

I can confirm that similar sort of issue is present with azuredevops_serviceendpoint_kubernetes. I am using microsoft/azuredevops v1.2.0

Reference comment: https://github.com/microsoft/terraform-provider-azuredevops/issues/918#issuecomment-2273127755

I have one question though at this moment. Is it safe to remove resources from state file like mentioned above?

It seems like a workaround and something that cant be done in prod environment. Is there no better approach to deal with this?