From f2cfbee41d59f003bb52ce00d1d61bcc30613abe Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 2 Jun 2026 01:17:21 +0800 Subject: [PATCH] fix: reuse env image from registry fallback --- deploy/templates/tekton/pipeline.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/deploy/templates/tekton/pipeline.yaml b/deploy/templates/tekton/pipeline.yaml index 860caa0..3f58d18 100644 --- a/deploy/templates/tekton/pipeline.yaml +++ b/deploy/templates/tekton/pipeline.yaml @@ -148,14 +148,41 @@ spec: AGENTRUN_REGISTRY_PREFIX="$(params.registry-prefix)" \ node <<'NODE' const { readFileSync, writeFileSync } = require("node:fs"); + const { execFileSync } = require("node:child_process"); const envIdentity = process.env.AGENTRUN_ENV_IDENTITY; const revision = process.env.AGENTRUN_REVISION; const gitopsBranch = process.env.AGENTRUN_GITOPS_BRANCH; + const registryPrefix = process.env.AGENTRUN_REGISTRY_PREFIX; let previousService = null; try { const catalog = JSON.parse(readFileSync(process.env.AGENTRUN_PREV_CATALOG, "utf8")); previousService = (catalog.services || []).find((item) => item.serviceId === "agentrun-mgr" && item.envIdentity === envIdentity && /^sha256:[a-f0-9]{64}$/.test(item.envDigest || item.digest || "")) || null; } catch {} + if (previousService === null) { + try { + const digest = execFileSync("curl", ["-fsSI", "-H", "Accept: application/vnd.docker.distribution.manifest.v2+json", `http://127.0.0.1:5000/v2/agentrun/agentrun-mgr-env/manifests/${envIdentity}`], { encoding: "utf8" }) + .split(/\r?\n/) + .map((line) => line.split(": ")) + .find(([key]) => String(key).toLowerCase() === "docker-content-digest")?.[1] + ?.trim(); + if (/^sha256:[a-f0-9]{64}$/.test(digest || "")) { + previousService = { + serviceId: "agentrun-mgr", + artifactKind: "env-reuse", + status: "registry-reuse", + image: `${registryPrefix}/agentrun-mgr-env:${envIdentity}`, + digest, + repositoryDigest: `${registryPrefix}/agentrun-mgr-env@${digest}`, + imageTag: envIdentity, + envIdentity, + envImage: `${registryPrefix}/agentrun-mgr-env:${envIdentity}`, + envDigest: digest, + envRepositoryDigest: `${registryPrefix}/agentrun-mgr-env@${digest}`, + bootCommit: null, + }; + } + } catch {} + } const reused = previousService !== null; const plan = { lane: "v0.1",