microsoft / terraform-provider-azuredevops

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

`azuredevops_serviceendpoint_kubernetes` - ServiceEndpoint resource crashing - terraform-provider-azuredevops_v1.0.1 plugin crashed! #1088

Closed ankurkapoor closed 4 months ago

ankurkapoor commented 4 months ago

Community Note

Terraform (and Azure DevOps Provider) Version

v1.8.2

Affected Resource(s)

Terraform Configuration Files

data "azuredevops_project" "ado_project" {
  name = "ABC"
}
resource "azuredevops_serviceendpoint_kubernetes" "kubernetes" {
  project_id            = data.azuredevops_project.ado_project.id
  service_endpoint_name = "ADO-ServiceConnection-Kubernetes-${var.environment}"
  apiserver_url         = "https://${azurerm_kubernetes_cluster.aks.fqdn}"
  authorization_type    = "Kubeconfig"
  kubeconfig {
    kube_config = azurerm_kubernetes_cluster.aks.kube_config_raw
  }
}

resource "azuredevops_pipeline_authorization" "kubernetes" {
  project_id  = data.azuredevops_project.ado_project.id
  resource_id = azuredevops_serviceendpoint_kubernetes.kubernetes.id
  type        = "endpoint"
}

Debug Output

Panic Output

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

goroutine 84 [running]: github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.resourceServiceEndpointKubernetesRead(0x0?, {0xd61b20?, 0xc00041b1e0}) github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_kubernetes.go:219 +0xb6 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).read(0x10966a0?, {0x10966a0?, 0xc000356ea0?}, 0xd?, {0xd61b20?, 0xc00041b1e0?}) 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(0xc00038ba40, {0x10966a0, 0xc000356ea0}, 0xc000558a90, {0xd61b20, 0xc00041b1e0}) 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(0xc000358720, {0x10966a0?, 0xc000356d80?}, 0xc00057f6c0) 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(0xc0001a3040, {0x10966a0?, 0xc0003565a0?}, 0xc000546600) 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({0xedf280?, 0xc0001a3040}, {0x10966a0, 0xc0003565a0}, 0xc0000b2af0, 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, {0x1099400, 0xc00021a4e0}, 0xc0004d1b00, 0xc0003da630, 0x16242d0, 0x0) google.golang.org/grpc@v1.56.3/server.go:1335 +0xde3 google.golang.org/grpc.(Server).handleStream(0xc0000003c0, {0x1099400, 0xc00021a4e0}, 0xc0004d1b00, 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_v1.0.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.

[warning]Can't find loc string for key: TerraformPlanFailed

[error]Error: TerraformPlanFailed 1

Expected Behavior

The build/destroy plan should execute without errors. Also if there is some issue with service endpoint, it shoud at least be reported properly.

Actual Behavior

β”‚ Error: Plugin did not respond β”‚ β”‚ with module.aks.azuredevops_serviceendpoint_kubernetes.kubernetes, β”‚ on .terraform/modules/aks/aks/ado_agent.tf line 26, in resource "azuredevops_serviceendpoint_kubernetes" "kubernetes": β”‚ 26: resource "azuredevops_serviceendpoint_kubernetes" "kubernetes" {

Steps to Reproduce

  1. terraform init
  2. terraform plan

Important Factoids

Nothing specific. This has been working fine earlier but I think when the TF state got issues and the service connection was manually removed, after that even after resetting the TF state, its hard to get it resolved.

References