azure - Terraform INIT 在 ACI 上使用 azure Devops 自托管代理失败
问题描述
我在 azure devops 中有 2 个 terraform 管道:
1- 提供 vnet 和 azure 容器实例并将其注册为代理池节点。2-使用自托管代理池,该池使用来自第一个管道的 aci 来提供其他东西。
第二个管道在到达 init 时失败,并显示以下消息
##[error]Terraform command 'init' failed with exit code '1'.: Failed to get existing workspaces: containers.Client#ListBlobs: Failure sending request: StatusCode=0 -- Original Error: Get "https://xxx.blob.core.windows.net/terraform?comp=list&prefix=xxx-infra-dev.tfstateenv%253A&restype=container": dial tcp xx.xxx.xx.x:443: connect: connection timed out
这就是我为代理提供 ACI 的方式:
terraform {
required_version = "~> 0.13"
backend "azurerm" {}
}
provider "azurerm" {
version = "~> 2.8.0"
skip_provider_registration = true
features {}
}
module "aci-devops-agent" {
source = "Azure/aci-devops-agent/azurerm"
resource_group_name = var.resource_group_name
location = var.location
enable_vnet_integration = true
create_resource_group = false
vnet_resource_group_name = var.resource_group_name
vnet_name = local.virtual_network_name
subnet_name = data.azurerm_subnet.subnet["mgmt"].name
linux_agents_configuration = {
agent_name_prefix = "aci-${var.environment}-${var.app_name}"
agent_pool_name = var.agent_pool_name
count = 1,
docker_image = "jcorioland/aci-devops-agent"
docker_tag = "0.2-linux"
cpu = 1
memory = 4
}
azure_devops_org_name = "xxx"
azure_devops_personal_access_token = var.pat
}
并成功检测到代理
问题出在哪里 ?我感觉它来自 ACI,可能与令牌有关,但看起来都是绿色的?
感谢你的帮助 !
解决方案
解决方案: 是在 ADO 中重新创建 PAT 令牌。
故障排除步骤:
检查/azp/agent/_diag/Agent_xxx-utc.log
并看到 401 错误消息:
[2020-12-13 07:47:36Z INFO RSAFileKeyManager] Loading RSA key parameters from file /azp/agent/.credentials_rsaparams
[2020-12-13 07:47:36Z INFO VisualStudioServices] AAD Correlation ID for this token request: Unknown
[2020-12-13 08:09:17Z INFO MessageListener] No message retrieved from session 'xxx' within last 30 minutes.
[2020-12-13 08:39:17Z INFO MessageListener] No message retrieved from session 'xxx' within last 30 minutes.
[2020-12-13 08:42:37Z WARN VisualStudioServices] Authentication failed with status code 401.
然后重新创建了 PAT,它工作正常。
笔记:
- terraform 错误消息具有误导性,因为它是 dial
tcp xx.xxx.xx.x:443: connect: connection timed out
- 新 PAT 令牌的创建与旧令牌完全一样,我不知道为什么新令牌有效而旧令牌无效。
推荐阅读
- typeahead.js - xEditable Typahead - 需要从远程源 json 值设置 data-pk
- javascript - ES 模块脚本的 CommonJS 包装器
- css - 弹性项目内的可滚动div
- html - 如果超出屏幕高度React Bootstrap,如何自动切断图像?
- mysql - 检索唯一访问 sql 不起作用 mysql
- swift - Swift 从 paymentContextDidChange 获取 stripeId
- socket.io - 如何防止 websocket 打开握手超时?
- java - Java或C#的TFF文件内部信息提取
- html - 根据从表单发布信息的函数的结果激活单独的函数
- javascript - Javascript如何在单击时更改按钮的颜色?