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

azuredevops_serviceendpoint_kubernetes crashing when running Terraform Plan with AzureDevOps pipeline & Job Access Token #1132

Open
ankurkapoor opened this issue Aug 15, 2024 · 4 comments
Labels

Comments

@ankurkapoor
Copy link

ankurkapoor commented Aug 15, 2024

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

Terraform - 1.8.2
Azure DevOps Provider - terraform-provider-azuredevops_v1.2.0

Affected Resource(s)

  • azuredevops_serviceendpoint_kubernetes

Terraform Configuration Files

resource "azuredevops_serviceendpoint_kubernetes" "kubernetes" {
  project_id            = data.azuredevops_project.ado_project.id
  service_endpoint_name = "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
  }
}

Debug Output

[

](https://gist.github.com/ankurkapoor/3c64f983573faa121eccd0f0fdfc45a9)

Panic Output

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

goroutine 101 [running]:
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.resourceServiceEndpointKubernetesRead(0x0?, {0xdb5a20?, 0xc0000d1860})
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(0x110e300?, {0x110e300?, 0xc0004dec90?}, 0xd?, {0xdb5a20?, 0xc0000d1860?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:712 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc00035c8c0, {0x110e300, 0xc0004dec90}, 0xc000588680, {0xdb5a20, 0xc0000d1860})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00031cd98, {0x110e300?, 0xc0004deb70?}, 0xc0000b7a00)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x497
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0002cf220, {0x110e300?, 0xc0004de5a0?}, 0xc0003db5c0)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:748 +0x49e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xf44a60?, 0xc0002cf220}, {0x110e300, 0xc0004de5a0}, 0xc000538380, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000003c0, {0x1111220, 0xc00038a1a0}, 0xc0004ee900, 0xc000424780, 0x16cad90, 0x0)
google.golang.org/[email protected]/server.go:1335 +0xde3
google.golang.org/grpc.(*Server).handleStream(0xc0000003c0, {0x1111220, 0xc00038a1a0}, 0xc0004ee900, 0x0)
google.golang.org/[email protected]/server.go:1712 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:947 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:958 +0x15c

Error: The terraform-provider-azuredevops_v1.2.0 plugin crashed!

Expected Behavior

Just to give some more details about the setup, I am running Terraform using ADO pipeline and under TerraformTaskV4 task. When using the AZDO_PERSONAL_ACCESS_TOKEN: $(System.AccessToken) the provider plugin crashes.

  - task: TerraformTaskV4@4
    name: terraformPlan
    displayName: Terraform Plan
    inputs:
      provider: 'azurerm'
      command: 'plan'
      commandOptions: '-input=false -out terraform.tfplan ${{ parameters.varFile }} ${{ parameters.extraArgs }}'
      workingDirectory: '$(System.DefaultWorkingDirectory)/terraform/'
      environmentServiceNameAzureRM: ${{ variables.serviceARM }}
    env:
      AZDO_PERSONAL_ACCESS_TOKEN: $(System.AccessToken) 
      AZDO_ORG_SERVICE_URL: $(ado-url)

Actual Behavior

Terraform provider plugin crashes. Also tested with latest version 1.2.0 and its same behaviour.

Steps to Reproduce

  1. terraform plan

Important Factoids

References

  • #0000
@hugostackoverflow
Copy link

hugostackoverflow commented Aug 20, 2024

The same is happening with azuredevops_serviceendpoint_azurecr

using:

==============================================================================
Task         : Terraform CLI
Description  : Execute terraform cli commands
Version      : 1.1.2
Author       : Charles Zipp
Help         : 
==============================================================================
Terraform v1.8.0
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.113.0
+ provider registry.terraform.io/microsoft/azuredevops v1.2.0

error:

Error: Plugin did not respond
│ 
│   with azuredevops_serviceendpoint_azurecr.acr_service_endpoint,
│   on main.tf line 148, in resource "azuredevops_serviceendpoint_azurecr" "acr_service_endpoint":
│  148: resource "azuredevops_serviceendpoint_azurecr" "acr_service_endpoint" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-azuredevops_v1.2.0 plugin:

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

goroutine 68 [running]:
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.resourceServiceEndpointAzureCRRead(0x0?, {0xdb5a20?, 0xc0004b6000})
	github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_azurecr.go:164 +0xb6
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x110e300?, {0x110e300?, 0xc0002796e0?}, 0xd?, {0xdb5a20?, 0xc0004b6000?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:712 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0003c20e0, {0x110e300, 0xc0002796e0}, 0xc0003ffe10, {0xdb5a20, 0xc0004b6000})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00037cd80, {0x110e300?, 0xc0002795c0?}, 0xc0004553c0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x497
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc00032f360, {0x110e300?, 0xc000278de0?}, 0xc0005132c0)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:748 +0x49e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xf44a60?, 0xc00032f360}, {0x110e300, 0xc000278de0}, 0xc00019acb0, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000003c0, {0x1111220, 0xc00041e1a0}, 0xc0005be240, 0xc00040a780, 0x16cad90, 0x0)
	google.golang.org/[email protected]/server.go:1335 +0xde3
google.golang.org/grpc.(*Server).handleStream(0xc0000003c0, {0x1111220, 0xc00041e1a0}, 0xc0005be240, 0x0)
	google.golang.org/[email protected]/server.go:1712 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/[email protected]/server.go:947 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:958 +0x15c

Error: The terraform-provider-azuredevops_v1.2.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.

@bwesolowskicf
Copy link

Hi, I got the same error as @hugostackoverflow because I manually removed the service endpoint from Azure Devops, while it was still in the terraform state. I was able to unblock myself by manually removing it from the tf state. It's a provider bug nonetheless.

@hugostackoverflow
Copy link

Hi, I got the same error as @hugostackoverflow because I manually removed the service endpoint from Azure Devops, while it was still in the terraform state. I was able to unblock myself by manually removing it from the tf state. It's a provider bug nonetheless.

True, I manually erased the identity then the service connection - We did this because plan was always showing changes, even if no changes where made. We added ignore_changes in the meantime.

@bwesolowskicf are you experiencing the same ?

@bwesolowskicf
Copy link

We're sometimes getting info that resources will be updated in place but it doesn't show what property of the object will be updated, so it might be something different.

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

4 participants