terraform -v
0.12.24
azuredevops 0.0.1
azuredevops_build_definitionresource "azuredevops_build_definition" "azure_iac" {
project_id = azuredevops_project.module.id
name = "${var.workload}-azure-iac"
path = "\\"
agent_pool_name = var.agent_pool_name
ci_trigger {
use_yaml = true
}
pull_request_trigger {
use_yaml = true
forks {
enabled = false
share_secrets = false
}
}
repository {
repo_id = "${bitbucket_repository.module.owner}/${bitbucket_repository.module.name}"
repo_type = "Bitbucket"
branch_name = "master"
service_connection_id = azuredevops_serviceendpoint_bitbucket.bitbucket.id
yml_path = "/azure-pipeline.yml"
}
variable {
name = "connectionName"
value = azuredevops_serviceendpoint_azurerm.azure_iac.service_endpoint_name
is_secret = false
}
variable {
name = "servicePrincipalId"
value = azuread_application.module.application_id
is_secret = false
}
variable {
name = "servicePrincipalKey"
secret_value = random_password.module.result
is_secret = true
}
variable {
name = "tenantId"
value = var.tenant_id
is_secret = false
}
variable {
name = "subscriptionId"
value = var.subscription_id
is_secret = false
}
dynamic "variable" {
for_each = contains(var.additional_variables, "TF_VAR_bitbucket_username") ? [1] : []
content {
name = "TF_VAR_bitbucket_username"
value = var.bitbucket_username
is_secret = false
}
}
dynamic "variable" {
for_each = contains(var.additional_variables, "TF_VAR_bitbucket_secret") ? [1] : []
content {
name = "TF_VAR_bitbucket_secret"
secret_value = var.bitbucket_secret
is_secret = true
}
}
}
https://gist.github.com/edwardwu-servian/e30615e48e86b60a5bc7ad0fec2a10de
This resource has been applied previously. Plan should successfully complete without any change.
Plan failed with output
Error: rpc error: code = Unavailable desc = transport is closing
Error: rpc error: code = Unavailable desc = transport is closing
terraform planCurrently the workaround I found is removing azuredevops_build_definition from terraform state and delete the pipeline from Azure DevOps
Hi @edwardwu-servian Thanks for your feed back. Can you check the agen pool used in this build definition is still exist? This error happened when the agent pool not exist.
@xuzhang3 thanks for getting back quickly. The agent pool has been removed and recreated with the same name. I assume the agent pool id may be different
@edwardwu-servian Delete and recreate, the id of the agent pool will be changed. Terraform can't detect this if you change the resource out of terraform.
@xuzhang3 azuredevops_build_definition is expecting agent_pool_name, may be it should be agent_pool_id instead? although in the state file there is no reference of agent pool id
@edwardwu-servian In azuredevops_build_definition, only agent_pool name is used, You can use azuredevops_agent_pool to manage the agent pool.
@xuzhang3 we are using vmss agent pool. it does not seemed to be supported by resource azuredevops_agent_pool. There's a data source for azuredevops_agent_pool but I don't see how using data.azuredevops_agent_pool.pool.name is different from plain text input for agent_pool_name, could you please clarify?
@edwardwu-servian No big difference in your scenario.
@xuzhang3 thanks. we've decided to remove agent_pool_name since it is an optional input and leverage the pipeline yaml to explicitly specify the agent pool.
Its kind like ABA issue, for Terraform the resource never changed. But for service the resource has been chhanged.
yeah it makes sense. was just hoping the backend could handle this in a more delicate manner. thanks again!
yeah it makes sense. was just hoping the backend could handle this in a more delicate manner. thanks again!
I have submit a PR for this issue.
I got the same crash. However, the agent pool did not change at all, same for the permissions. This just started happening, but it succeeded a couple of times before that.
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
azuredevops_git_repository.repo: Refreshing state... [id=8bd8e4ca-7f3d-4439-994f-b60dd2b6d067]
azuredevops_build_definition.build: Refreshing state... [id=125]
Error: rpc error: code = Unavailable desc = transport is closing
panic: runtime error: invalid memory address or nil pointer dereference
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xddd822]
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4:
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: goroutine 51 [running]:
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/build.flattenBuildDefinition(0xc000268e70, 0xc00015fce0, 0xc0000e8ba0, 0x24)
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/build/resource_build_definition.go:317 +0x522
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/build.resourceBuildDefinitionRead(0xc000268e70, 0xee91e0, 0xc00031e300, 0xc000268e70, 0x0)
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/build/resource_build_definition.go:397 +0x302
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000191500, 0xc0000f2d20, 0xee91e0, 0xc00031e300, 0xc0001234c0, 0x0, 0x0)
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azuredevops/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:455 +0x119
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc000122b38, 0x137d860, 0xc0004fb4a0, 0xc0000f2be0, 0xc000122b38, 0xc0004fb4a0, 0xc00053ba48)
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azuredevops/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:525 +0x3d8
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x10c2d20, 0xc000122b38, 0x137d860, 0xc0004fb4a0, 0xc0005ea2a0, 0x0, 0x137d860, 0xc0004fb4a0, 0xc000556000, 0x1ae)
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azuredevops/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3153 +0x217
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: google.golang.org/grpc.(*Server).processUnaryRPC(0xc00015e000, 0x138ab80, 0xc000001800, 0xc0005b4d00, 0xc0001aa330, 0x1af81d0, 0x0, 0x0, 0x0)
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azuredevops/vendor/google.golang.org/grpc/server.go:995 +0x460
2020-08-14T15:30:23.920Z [DEBUG] plugin.terraform-provider-azuredevops_v0.0.1_x4: google.golang.org/grpc.(*Server).handleStream(0xc00015e000, 0x138ab80, 0xc000001800, 0xc0005b4d00, 0x0)
Small update: looks like this happened because the PAT no longer had the permission to view all the agent pools
Small update: looks like this happened because the PAT no longer had the permission to view all the agent pools
Hi @sdebruyn This issue was because you delete the agent pool bind to the pipeline.
Close this issue, feel free to reopen it if you have questions