Closed roryprimrose closed 3 weeks ago
@roryprimrose I cannot reproduce this error, from the source code, this error is because the buildDefinition.repository
cannot find. This could be some legacy changes from different API version result in different response body or there is some permissions to limit the repository read operation. I will enhance the null pointer check.
You can check the the build definition details by API : https://dev.azure.com/{org}/{project}/_apis/build/definitions/{denifinitionID}?api-version=5.1.
Thanks @xuzhang3. I found that it only happened on import. If I renamed the existing pipeline and then ran apply it was able to create the pipeline fine. Not a great solution because now we have old pipelines we need to hang on to due to the pipeline history but I was able to move forward.
Is there a reason you use the old build api rather than the new pipeline api?
I'm assuming it is so that you can support old build definitions as well as the newer pipelines.
@roryprimrose we're still using the 5.1 REST API because a newer one wasn't available so far for GO. @nechvatalp is working on the 6.0 REST API right now. There are still some issues with generation process; ref to #204
I encounter a very similar problem with Terraform 1.1.0 (or 1.0.4 or 1.0.11) and the Azure DevOps Provider 0.1.7 and 0.1.8.:
When I run terraform plan
in the project my colleague worked with before, the azuredevops plugin crashes:
β·
β Error: Plugin did not respond
β
β with module.azure-devops.azuredevops_serviceendpoint_github_enterprise.ghe,
β on azure-devops/service_connection.tf line 1, in resource "azuredevops_serviceendpoint_github_enterprise" "ghe":
β 1: resource "azuredevops_serviceendpoint_github_enterprise" "ghe" {
β
β 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.azure-devops.azuredevops_serviceendpoint_azurerm.infrastructure_subscription,
β on azure-devops/service_connection.tf line 12, in resource "azuredevops_serviceendpoint_azurerm" "infrastructure_subscription":
β 12: resource "azuredevops_serviceendpoint_azurerm" "infrastructure_subscription" {
β
β The plugin.(*GRPCProvider).UpgradeResourceState request was cancelled.
β΅
β·
β Error: Request cancelled
β
β with module.azure-devops.azuredevops_serviceendpoint_azurecr.container_registry,
β on azure-devops/service_connection.tf line 26, in resource "azuredevops_serviceendpoint_azurecr" "container_registry":
β 26: resource "azuredevops_serviceendpoint_azurecr" "container_registry" {
β
β The plugin.(*GRPCProvider).UpgradeResourceState request was cancelled.
β΅
Stack trace from the terraform-provider-azuredevops_v0.1.8 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1b38dae]
goroutine 41 [running]:
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.flattenServiceEndpointGitHubEnterprise(0xc0001a6850, 0xc000166a80, 0xc00071ea90)
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint/resource_serviceendpoint_github_enterprise.go:53 +0x4e
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint.genServiceEndpointReadFunc.func1(0xc0001a6850, 0x1bdd7e0, 0xc00069a000, 0xc0001a6850, 0x0)
github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint/commons.go:210 +0x278
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000322780, 0xc000744cd0, 0x1bdd7e0, 0xc00069a000, 0xc0000ac298, 0x0, 0x0)
github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:470 +0x12e
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc000288be0, 0x1fd59b0, 0xc0007af380, 0xc000281140, 0xc000288be0, 0xc0007af380, 0xc00056bba0)
github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:535 +0x3dd
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x1d8d040, 0xc000288be0, 0x1fd59b0, 0xc0007af380, 0xc0002810e0, 0x0, 0x1fd59b0, 0xc0007af380, 0xc00013edc0, 0x2a4)
github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3269 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00034b6c0, 0x1fe3918, 0xc00009b380, 0xc0000b6a00, 0xc00035e8d0, 0x25ce550, 0x0, 0x0, 0x0)
google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc00034b6c0, 0x1fe3918, 0xc00009b380, 0xc0000b6a00, 0x0)
google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000290380, 0xc00034b6c0, 0x1fe3918, 0xc00009b380, 0xc0000b6a00)
google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd
Error: The terraform-provider-azuredevops_v0.1.8 plugin crashed!
@andreassiegel How does the HCL code look like, that creates the Service Endpoint resource for GitHub Enterprise? The provider crashes at the location below. So something's wrong how the authorization settings are handled.
And because the error is related to a different resource, would you mind creating a new issue? Would be easier to track.
I get that kind of error mostly testing on my local machine. I suspect it is usually http/networking failures and running it again works fine.
I wish rerunning would fix it. I get the error all the time recently, and always in the same spot.
But you're right, I get the error running on the local machine. The script is not supposed to be run somewhere in a pipeline because it is setting up pipelines, etc. itself.
Try running terraform through fiddler so you can see the https traffic. That might show something interesting.
I have the same issue that the import of existing pipelines works in some cases and in some others not. I get the same error like this one.
I tested the link you provided to check the repo properties: https://dev.azure.com/{org}/{project}/_apis/build/definitions/{denifinitionID}?api-version=5.1.
In many cases there are no repository properties. Then the import fails.
A workaround is to add a property via API: https://stackoverflow.com/questions/65027909/how-to-update-azure-devops-build-definition-source-from-azure-repos-to-github-us
Community Note
Terraform (and Azure DevOps Provider) Version
Terraform: 1.0.11 Azure DevOps provider: 0.1.7
Affected Resource(s)
azuredevops_build_definition
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Build definition should be imported into state.
Actual Behavior
I ran about 40 imports into state via an AzDO pipeline. About 50% of them failed on this memory issue.
Steps to Reproduce
terraform import -input=false *** 'module.azdo_pipeline[\"70109eaf-836e-4abe-a042-d5110b67f067\"].azuredevops_build_definition.pipeline' MyProject/PipelineId
Important Factoids
References
0000