每次我的 TC-agent docker 图像运行时,它都会作为一个新的和独特的构建代理接收

Every time my TC-agent docker image runs, it's received as a new and unique buildagent

我们已经设置了一个 Amazon EC2 代理,它在启动时 运行 是一个基于 jetbrains/teamcity-minimal-agent image(标签 2020.2.1)的图像。代理由 TeamCity Cloud 配置文件激活和停用。

一切正常,除了:每次启动代理时,TeamCity 服务器都会将其注册为“新”代理(属于同一云映像)。很快,我们就有了几十个不同的、“不同的”代理,都在同一个云配置文件中。

这是我们的云配置文件列表,充满了代理:

下面是其中一些代理的列表 -- 相同的名称,加上一个递增的计数器:

这是我们在 运行 机器启动时执行的 docker 命令:

docker run -d -it -e SERVER_URL=$OUR_URL -e AGENT_NAME="Software-Linux-dockerAgent-01" \
    -v /home/ubuntu/ci_agent/agent_config:/data/teamcity_agent/conf \
    -v /home/ubuntu/ci_agent/work:/opt/buildagent/work \
    -v /home/ubuntu/ci_agent/system:/opt/buildagent/system \
    my_linux_ci_agent:1.4

服务器日志显示每次代理连接时,它“没有定义名称”,因此会为其生成一个新名称。

[2021-01-17 15:13:44,401]   INFO -    jetbrains.buildServer.AGENT - Set generated name "Software-Linux-EC2-Agent-01-i-09307d6796743bda4-2" to agent "" {id=66} as it had no name defined.
[2021-01-17 16:29:54,529]   INFO -    jetbrains.buildServer.AGENT - Set generated name "Software-Linux-EC2-Agent-01-i-09307d6796743bda4-3" to agent "" {id=67} as it had no name defined.
[2021-01-17 23:21:29,798]   INFO -    jetbrains.buildServer.AGENT - Set generated name "Software-Linux-EC2-Agent-01-i-09307d6796743bda4-4" to agent "" {id=68} as it had no name defined.
[2021-01-18 09:27:10,853]   INFO -    jetbrains.buildServer.AGENT - Set generated name "Software-Linux-EC2-Agent-01-i-09307d6796743bda4-5" to agent "" {id=69} as it had no name defined.

可能是什么原因造成的,我该如何解决?


关于我目前检查和尝试的内容的更多信息。

我希望代理配置数据保存在 /data/teamcity_agent/conf 卷中,这应该足以在下一个 运行 上“识别”代理。 可以看到 agent_config/buildAgent.properties 确实记录了服务器分配的名称和授权令牌:

## The unique name of the agent used to identify this agent on the TeamCity server
## Use blank name to let server generate it.
## By default, this name would be created from the build agent's host name
name=Software-Linux-EC2-Agent-01-i-09307d6796743bda4-9

(...)

## A token which is used to identify this agent on the TeamCity server for agent authorization purposes.
## It is automatically generated and saved back on the first agent connection to the server.
authorizationToken=eb0b786556d8f12c1c8917cb10dfdd14

但是下次启动 docker 图像时,它会被新值覆盖:

## The unique name of the agent used to identify this agent on the TeamCity server
## Use blank name to let server generate it.
## By default, this name would be created from the build agent's host name
name=Software-Linux-EC2-Agent-01-i-09307d6796743bda4-10

(...)

## A token which is used to identify this agent on the TeamCity server for agent authorization purposes.
## It is automatically generated and saved back on the first agent connection to the server.
authorizationToken=f966d0c9f6e44fe284243edd19cfba69

我在 TeamCity 社区论坛上发现了一个类似的 post,其中 Multiple TC build agents on a single AWS EC2 instance connected with the Agent Cloud plugin generate new agent names for each run,症状听起来非常相似。但就我而言,实例上只有一个构建代理 运行ning。

问题似乎是在配置初始化中在路径 /opt/buildagent/conf/ 上创建了一个 Amazon 标记文件,其名称格式为 amazon-i-$ID.

标准说明不包括将 /opt/buildagent/conf/ 持久化为一个卷,但这应该可以解决问题。