fix(deploy): 在线更新 - 兼容旧版 Host Updater 升级到独立 Agent 容器

v1.5.8.x 的 Host Updater 只注入 backend/web 镜像且不生成 Agent Token,目标 Compose 强制要求 CANVAS_YINGCE_AGENT_IMAGE 与 YINGCE_AGENT_TOKEN 导致预检失败。部署 Compose 缺省时回退到同版本 Agent 镜像标签与更新器 Token,新版更新器后续更新仍写入 digest 与独立 Token;拉取阶段同时拉取 yingce-agent 镜像,避免摘要校验找不到本地镜像。
This commit is contained in:
ddcat666
2026-09-30 13:01:09 +08:00
parent 18dbdf7403
commit 0ad2c70d78
3 changed files with 25 additions and 4 deletions

View File

@@ -271,7 +271,7 @@ func (m *Manager) runUpdate(fromVersion, targetVersion string) {
m.setPhase(PhasePulling, "拉取目标版本镜像")
targetImages := immutableImageRefs(m.config.Repository, targetVersion)
if err := m.composeWithImages(nextCompose, targetVersion, targetImages, m.config.StepTimeout, nil, "pull", "backend", "web"); err != nil {
if err := m.composeWithImages(nextCompose, targetVersion, targetImages, m.config.StepTimeout, nil, "pull", "backend", "web", "yingce-agent"); err != nil {
m.failWithoutRollback(PhaseFailed, err)
return
}

View File

@@ -186,3 +186,23 @@ func TestWriteComposeEnvOverrideReplacesImageRefs(t *testing.T) {
t.Fatalf("unexpected override env: %q", value)
}
}
// v1.5.8.x 的 Host Updater 只注入 backend/web 镜像,也不会生成 Agent Token。
// 部署 Compose 中 Agent 相关变量必须有回退值,否则旧更新器的预检会直接失败。
func TestDeployComposeAgentVariablesFallbackForLegacyUpdater(t *testing.T) {
data, err := os.ReadFile(filepath.Join("..", "..", "..", "docker-compose.deploy.yml"))
if err != nil {
t.Fatal(err)
}
compose := string(data)
for _, required := range []string{"${CANVAS_YINGCE_AGENT_IMAGE:?", "${YINGCE_AGENT_TOKEN:?"} {
if strings.Contains(compose, required) {
t.Errorf("docker-compose.deploy.yml must not hard-require %s…}", required)
}
}
for _, fallback := range []string{"${CANVAS_YINGCE_AGENT_IMAGE:-", "${YINGCE_AGENT_TOKEN:-${CANVAS_UPDATER_TOKEN:?"} {
if !strings.Contains(compose, fallback) {
t.Errorf("docker-compose.deploy.yml is missing fallback %s…}", fallback)
}
}
}