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

Provider Crash reading deleted Service Connection #918

Closed
FRUCHTiii opened this issue Nov 3, 2023 · 5 comments
Closed

Provider Crash reading deleted Service Connection #918

FRUCHTiii opened this issue Nov 3, 2023 · 5 comments
Labels

Comments

@FRUCHTiii
Copy link
Contributor

FRUCHTiii commented Nov 3, 2023

We create service connections, elastic agent pools and needed queues via terraform.
The inital creation runs fine as expected. If I delete the agent pool manual afterwards and try to re-apply the terraform code to create the agent pools again the provider crashes and destroys the state.

It seems like the provider is crashing while reading the deleted service connection.

My expected behaviour where that the resources are created again.

I was able to reproduce this behaviour all the time. And I tested v0.9.1 and v0.10.0 of the terraform provider and run into the same issue.

I was not able to fix the terraform state afterwards. So I had to restore an old state file.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and Azure DevOps Provider) Version

microsoft/azuredevops v0.9.1
microsoft/azuredevops v0.10.0
terraform v1.5.7

Affected Resource(s)

  • azuredevops_serviceendpoint_azurerm

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

╷
│ Error: Plugin did not respond
│ 
│   with module.agent_pools_qa["qa"].azuredevops_serviceendpoint_azurerm.sc_arm_agent_pool,
│   on modules/agent-pool/main.tf line 8, in resource "azuredevops_serviceendpoint_azurerm" "sc_arm_agent_pool":
│    8: resource "azuredevops_serviceendpoint_azurerm" "sc_arm_agent_pool" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵
╷
│ Error: Request cancelled
│ 
│   with module.agent_pools_prd["prd"].azuredevops_serviceendpoint_azurerm.sc_arm_agent_pool,
│   on modules/agent-pool/main.tf line 8, in resource "azuredevops_serviceendpoint_azurerm" "sc_arm_agent_pool":
│    8: resource "azuredevops_serviceendpoint_azurerm" "sc_arm_agent_pool" {
│ 
│ The plugin.(*GRPCProvider).UpgradeResourceState request was cancelled.
╵
╷
│ Error: Request cancelled
│ 
│   with module.agent_pools_alm["alm"].azuredevops_serviceendpoint_azurerm.sc_arm_agent_pool,
│   on modules/agent-pool/main.tf line 8, in resource "azuredevops_serviceendpoint_azurerm" "sc_arm_agent_pool":
│    8: resource "azuredevops_serviceendpoint_azurerm" "sc_arm_agent_pool" {
│ 
│ The plugin.(*GRPCProvider).UpgradeResourceState request was cancelled.


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

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

goroutine 307 [running]:
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.resourceServiceEndpointAzureRMRead(0x0?, {0xcc8c80?, 0xc000497080})
	github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_azurerm.go:184 +0xb2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xfbf3e0?, {0xfbf3e0?, 0xc00041d200?}, 0xd?, {0xcc8c80?, 0xc000497080?})
	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(0xc00032ca80, {0xfbf3e0, 0xc00041d200}, 0xc000332c30, {0xcc8c80, 0xc000497080})
	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(0xc0002f25b8, {0xfbf3e0?, 0xc00041cde0?}, 0xc0001061c0)
	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(0xc0002bf040, {0xfbf3e0?, 0xc00041c120?}, 0xc0003e1620)
	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({0xe27de0?, 0xc0002bf040}, {0xfbf3e0, 0xc00041c120}, 0xc000129570, 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(0xc0000003c0, {0xfc20e0, 0xc000367860}, 0xc00059e480, 0xc00033de60, 0x14f37b0, 0x0)
	google.golang.org/grpc@v1.53.0/server.go:1336 +0xd13
google.golang.org/grpc.(*Server).handleStream(0xc0000003c0, {0xfc20e0, 0xc000367860}, 0xc00059e480, 0x0)
	google.golang.org/grpc@v1.53.0/server.go:1704 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.53.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.53.0/server.go:963 +0x28a

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


Expected Behavior

Recreate the deleted resources

Actual Behavior

Crash of the provider

Steps to Reproduce

  • Create Serice Connection via Terraform
  • Delete Service Connection manually
  • Apply Terraform Code

References

@FRUCHTiii FRUCHTiii changed the title Provider Crash while reapply code Provider Crash reading deleted Service Connection Nov 3, 2023
@FRUCHTiii
Copy link
Contributor Author

Same issue with v.0.10.0

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=0x8 pc=0xc24192]

goroutine 239 [running]:
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.resourceServiceEndpointAzureRMRead(0x0?, {0xcd0440?, 0xc00040d080})
	github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_azurerm.go:189 +0xb2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xfcbbc0?, {0xfcbbc0?, 0xc00015f950?}, 0xd?, {0xcd0440?, 0xc00040d080?})
	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(0xc00036ea80, {0xfcbbc0, 0xc00015f950}, 0xc0006748f0, {0xcd0440, 0xc00040d080})
	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(0xc0003345e8, {0xfcbbc0?, 0xc00015f350?}, 0xc00045aac0)
	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(0xc0002eefa0, {0xfcbbc0?, 0xc000695da0?}, 0xc00007cde0)
	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?, 0xc0002eefa0}, {0xfcbbc0, 0xc000695da0}, 0xc00020a540, 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(0xc0000003c0, {0xfce8c0, 0xc0003a9860}, 0xc000423680, 0xc00037ff80, 0x15078f0, 0x0)
	google.golang.org/grpc@v1.56.3/server.go:1335 +0xde3
google.golang.org/grpc.(*Server).handleStream(0xc0000003c0, {0xfce8c0, 0xc0003a9860}, 0xc000423680, 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.

@xuzhang3 xuzhang3 added the bug label Nov 7, 2023
@xuzhang3
Copy link
Collaborator

xuzhang3 commented Nov 7, 2023

@FRUCHTiii This issue is bit tricky, normally if the service connection has been deleted service will return a result of http code 404. But in this scenario service returns the result with code 200 but response is null

@AMoghrabi
Copy link

@xuzhang3 Thanks for fixing this. Do you know when the next release will be that will include this fix? Also, is there a workaround for now? I've tried re-creating the service connection but the plugin is still crashing, unfortunately.

Thanks!

@AMoghrabi
Copy link

Actually, it looks like just removing the service connection from the state file does the trick. Looking forward to the next release, thanks!

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Nov 9, 2023

@AMoghrabi New version will be available in the early Dec

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

No branches or pull requests

3 participants