fix: probe direct docker registry via host network

This commit is contained in:
Codex
2026-05-23 21:33:15 +00:00
parent baaa8338b9
commit 0ac5c6bdfe
2 changed files with 30 additions and 7 deletions
+26 -6
View File
@@ -25,6 +25,7 @@ const tektonTriggersReleaseUrl = `https://infra.tekton.dev/tekton-releases/trigg
const tektonTriggersInterceptorsUrl = `https://infra.tekton.dev/tekton-releases/triggers/previous/${tektonTriggersVersion}/interceptors.yaml`;
const providerGatewayWsEgressProxyUrl = "http://127.0.0.1:18789";
const ciCodeQueueImage = "unidesk-code-queue:dev";
const codeQueueDirectDockerBaseImage = "unidesk-code-queue:d601";
const providerDispatchCompletionLagMs = 45_000;
const ciRuntimeImages = [
"rancher/mirrored-pause:3.6",
@@ -1498,18 +1499,37 @@ function dockerArtifactDigest(repository: string, imageRef: string): string | nu
return null;
}
function directDockerRegistryCurl(args: string[], timeoutMs = 30_000): ReturnType<typeof runCommand> {
const local = runCommand(["curl", ...args], repoRoot, { timeoutMs });
if (local.exitCode === 0 && !local.timedOut) return local;
const basePresent = runCommand(["docker", "image", "inspect", codeQueueDirectDockerBaseImage], repoRoot, { timeoutMs: 30_000 });
if (basePresent.exitCode !== 0) return local;
return runCommand([
"docker",
"run",
"--rm",
"--network",
"host",
"--pull",
"never",
"--entrypoint",
"curl",
codeQueueDirectDockerBaseImage,
...args,
], repoRoot, { timeoutMs });
}
function registryManifestDigest(repository: string, tag: string): string | null {
const registry = "127.0.0.1:5000";
if (!repository.startsWith(`${registry}/`)) return null;
const repositoryPath = repository.slice(`${registry}/`.length);
if (repositoryPath.length === 0 || repositoryPath.includes("..") || tag.length === 0) return null;
const result = runCommand([
"curl",
const result = directDockerRegistryCurl([
"-fsSI",
"-H",
"Accept: application/vnd.docker.distribution.manifest.v2+json",
`http://${registry}/v2/${repositoryPath}/manifests/${tag}`,
], repoRoot, { timeoutMs: 30_000 });
], 30_000);
if (result.exitCode !== 0) return null;
const match = /^Docker-Content-Digest:\s*(sha256:[0-9a-f]{64})\s*$/imu.exec(result.stdout);
return match?.[1] ?? null;
@@ -1609,8 +1629,8 @@ async function publishUserServiceArtifactDirectDocker(options: CiPublishUserServ
const localImage = `${options.imageRepository}:${options.commit}`;
const buildContext = buildContextForService(options.serviceId, options.dockerfile);
const networkArgs = directDockerBuildNetworkArgs(options.serviceId);
const baseArgs = options.serviceId === "code-queue" && runCommand(["docker", "image", "inspect", "unidesk-code-queue:d601"], repoRoot, { timeoutMs: 30_000 }).exitCode === 0
? ["--build-arg", "CODE_QUEUE_BASE_IMAGE=unidesk-code-queue:d601"]
const baseArgs = options.serviceId === "code-queue" && runCommand(["docker", "image", "inspect", codeQueueDirectDockerBaseImage], repoRoot, { timeoutMs: 30_000 }).exitCode === 0
? ["--build-arg", `CODE_QUEUE_BASE_IMAGE=${codeQueueDirectDockerBaseImage}`]
: [];
try {
if (options.serviceId === "code-queue" && baseArgs.length === 0) {
@@ -1662,7 +1682,7 @@ async function publishUserServiceArtifactDirectDocker(options: CiPublishUserServ
const inspectLabels = runCommand(["docker", "image", "inspect", planned.imageRef, "--format", "{{ index .Config.Labels \"unidesk.ai/service-id\" }} {{ index .Config.Labels \"unidesk.ai/source-commit\" }}"], repoRoot, { timeoutMs: 30_000 });
assertCommandOk(inspectLabels, "inspect built image labels");
if (!inspectLabels.stdout.includes(`${options.serviceId} ${options.commit}`)) throw new Error(`direct docker image labels did not match ${options.serviceId}/${options.commit}`);
const registryCheck = runCommand(["curl", "-fsS", "http://127.0.0.1:5000/v2/"], repoRoot, { timeoutMs: 15_000 });
const registryCheck = directDockerRegistryCurl(["-fsS", "http://127.0.0.1:5000/v2/"], 15_000);
assertCommandOk(registryCheck, "D601 loopback artifact registry health");
const push = runCommand(["docker", "push", planned.imageRef], repoRoot, { timeoutMs: Math.max(options.waitMs, 10 * 60_000) });
assertCommandOk(push, "direct docker push");