【问题标题】:Terraform INIT failing with azure Devops self hosted agent on ACITerraform INIT 在 ACI 上使用 azure Devops 自托管代理失败
【发布时间】:2020-12-10 21:17:08
【问题描述】:

我在 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,可能与令牌有关,但看起来都是绿色的?

感谢您的帮助!

【问题讨论】:

    标签: azure azure-devops terraform


    【解决方案1】:

    您的第一个管道中创建的 ACI 的网络设置似乎存在问题。

    您可以检查 ACI 的网络设置,并确保您可以从 ACI 连接到互联网。

    请查看this blog 中的示例以在 ACI 上配置自托管代理。

    请参阅this similar issue

    【讨论】:

    • 感谢您的回答 Levei,我实际上是按照博客进行部署,并且 aci 有互联网,如果我转到 aci -> 容器日志,它会报告它正在收听工作并且它有这个错误,所以它与 azure devops 管道有关 - 互联网看起来不错
    【解决方案2】:

    解决方案: 是在 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 错误消息具有误导性,因为它是拨打 tcp xx.xxx.xx.x:443: connect: connection timed out
    • 新的 PAT 令牌的创建方式与旧令牌完全相同,我不知道为什么新的 PAT 有效而旧的无效。

    【讨论】:

      猜你喜欢
      • 2021-11-14
      • 2020-01-01
      • 1970-01-01
      • 2019-08-31
      • 2019-07-09
      • 1970-01-01
      • 2019-11-06
      • 2021-02-20
      • 2020-06-08
      相关资源
      最近更新 更多