From aae393367fbb207a46e68b4190509a53dd358076 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jul 2026 14:27:10 +0200 Subject: [PATCH] =?UTF-8?q?fix(cicd):=20=E4=BD=BF=E7=94=A8=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E8=81=94=E9=80=9A=E5=B0=B1=E7=BB=AA=E9=97=A8=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/deploy.yaml | 22 ++++++------ scripts/ci/runtime-ready.mjs | 34 +------------------ scripts/gitops-render.test.ts | 4 +++ .../src/gitops-render/tekton-manifests.mjs | 6 ++-- 4 files changed, 18 insertions(+), 48 deletions(-) diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index ed8d709e..67594908 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -587,7 +587,7 @@ lanes: runtimeKind: go-service entrypoint: cmd/hwlab-workbench-runtime/main.go artifactKind: go-service - healthPath: /health/ready + healthPath: /health/live healthPort: 6671 healthProbe: readiness: @@ -612,7 +612,7 @@ lanes: runtimeKind: go-service entrypoint: cmd/hwlab-user-billing/main.go artifactKind: go-service - healthPath: /health/ready + healthPath: /health/live healthPort: 6670 healthProbe: readiness: @@ -637,7 +637,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-project-management/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6672 healthProbe: readiness: @@ -661,7 +661,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-tasktree-api/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6673 componentPaths: - cmd/hwlab-tasktree-api/ @@ -677,7 +677,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-tasktree-worker/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6674 componentPaths: - cmd/hwlab-tasktree-worker/ @@ -692,7 +692,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-harnessrl-api/main.ts artifactKind: bun-command - healthPath: /readyz + healthPath: /health/live healthPort: 6675 componentPaths: - cmd/hwlab-harnessrl-api/ @@ -708,7 +708,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-harnessrl-worker/main.ts artifactKind: bun-command - healthPath: /readyz + healthPath: /health/live healthPort: 6676 componentPaths: - cmd/hwlab-harnessrl-worker/ @@ -725,7 +725,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-workbench-api/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6677 componentPaths: - cmd/hwlab-workbench-api/ @@ -743,7 +743,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-workbench-worker/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6678 componentPaths: - cmd/hwlab-workbench-worker/ @@ -759,7 +759,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-hwpod-api/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6681 componentPaths: - cmd/hwlab-hwpod-api/ @@ -775,7 +775,7 @@ lanes: runtimeKind: bun-command entrypoint: cmd/hwlab-hwpod-worker/main.ts artifactKind: bun-command - healthPath: /health/ready + healthPath: /health/live healthPort: 6682 componentPaths: - cmd/hwlab-hwpod-worker/ diff --git a/scripts/ci/runtime-ready.mjs b/scripts/ci/runtime-ready.mjs index 486c0e1a..8095f824 100644 --- a/scripts/ci/runtime-ready.mjs +++ b/scripts/ci/runtime-ready.mjs @@ -21,7 +21,6 @@ function requiredEnv(name) { const revision = requiredEnv("HWLAB_SOURCE_REVISION"); const runtimeNamespace = requiredEnv("HWLAB_RUNTIME_NAMESPACE"); const gitopsTarget = requiredEnv("HWLAB_GITOPS_TARGET"); -const argoApplication = requiredEnv("HWLAB_ARGO_APPLICATION"); const pipelineRun = process.env.HWLAB_TEKTON_PIPELINERUN || null; const taskRun = process.env.HWLAB_TEKTON_TASKRUN || null; const task = process.env.HWLAB_TEKTON_TASK || null; @@ -161,35 +160,6 @@ function maybeEmitProgress(state, stage, stageStartedAt, payload) { emit({ stage, status: "progress", durationMs: now - stageStartedAt, readinessMode, ...payload }); } -async function argoApplicationState() { - const path = "/apis/argoproj.io/v1alpha1/namespaces/argocd/applications/" + encodeURIComponent(argoApplication); - const response = await request("GET", path); - if (response.statusCode === 403) return { status: "rbac-denied", item: null, statusCode: response.statusCode }; - if (response.statusCode < 200 || response.statusCode > 299) return { status: "error", item: null, statusCode: response.statusCode, body: response.body.slice(0, 500) }; - return { status: "ok", item: response.json, statusCode: response.statusCode }; -} - -async function waitForArgoSyncedHealthy() { - const stageStartedAt = Date.now(); - const progressState = { lastProgressAt: 0 }; - while (Date.now() < deadline) { - const application = await argoApplicationState(); - if (application.status === "rbac-denied") return fail("argo-sync-health", "argocd-application-rbac-denied", stageStartedAt, { readinessMode }); - if (application.status !== "ok") return fail("argo-sync-health", "argocd-application-read-failed", stageStartedAt, { readinessMode, statusCode: application.statusCode, body: application.body || null }); - const syncStatus = application.item?.status?.sync?.status || null; - const healthStatus = application.item?.status?.health?.status || null; - const operationPhase = application.item?.status?.operationState?.phase || null; - const operationMessage = application.item?.status?.operationState?.message || null; - if (syncStatus === "Synced" && healthStatus === "Healthy") { - emit({ stage: "argo-sync-health", status: "succeeded", durationMs: Date.now() - stageStartedAt, readinessMode, syncStatus, healthStatus, operationPhase }); - return true; - } - maybeEmitProgress(progressState, "argo-sync-health", stageStartedAt, { syncStatus, healthStatus, operationPhase, operationMessage }); - await sleep(Math.min(pollMs, Math.max(0, deadline - Date.now()))); - } - return fail("argo-sync-health", "runtime-ready-wall-clock-timeout", stageStartedAt, { readinessMode }, "timeout"); -} - async function waitForArgoRefresh() { const stageStartedAt = Date.now(); const progressState = { lastProgressAt: 0 }; @@ -236,9 +206,7 @@ function fail(stage, reason, stageStartedAt, extra = {}, status = "failed") { emit({ stage: "runtime-ready", status: "started", readinessMode, observedServiceCount: observedServiceIds ? observedServiceIds.size : 0, timeoutMs }); try { - if (!observedServiceIds) { - if (await waitForArgoSyncedHealthy()) await waitForWorkloads(); - } else if (await waitForArgoRefresh()) { + if (await waitForArgoRefresh()) { await waitForWorkloads(); } } catch (error) { diff --git a/scripts/gitops-render.test.ts b/scripts/gitops-render.test.ts index 9f260be7..9536c811 100644 --- a/scripts/gitops-render.test.ts +++ b/scripts/gitops-render.test.ts @@ -223,6 +223,10 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots assert.match(pipeline, /node scripts\/run-bun\.mjs test cmd\/hwlab-codex-api-responses-forwarder\/main\.test\.ts/u); assert.doesNotMatch(pipeline, /cmd\/hwlab-codex-api-responses-forwarder\/main\.mjs/u); const runtimeReadySource = await readFile(path.join(process.cwd(), "scripts/ci/runtime-ready.mjs"), "utf8"); + assert.doesNotMatch(runtimeReadySource, /argo-sync-health|healthStatus === "Healthy"/u); + assert.doesNotMatch(runtimeReadySource, /HWLAB_ARGO_APPLICATION/u); + assert.match(runtimeReadySource, /if \(await waitForArgoRefresh\(\)\) \{\s+await waitForWorkloads\(\);/u); + assert.ok(!JSON.stringify(pipelineJson).includes("argo-application")); assert.match(runtimeReadySource, /process\.exitCode = 1/u); assert.match(runtimeReadySource, /item\.metadata\?\.labels\?\.\["hwlab\.pikastech\.local\/source-commit"\]/u); diff --git a/scripts/src/gitops-render/tekton-manifests.mjs b/scripts/src/gitops-render/tekton-manifests.mjs index b5803c10..9bfc36d3 100644 --- a/scripts/src/gitops-render/tekton-manifests.mjs +++ b/scripts/src/gitops-render/tekton-manifests.mjs @@ -450,7 +450,7 @@ function runtimeReadyTask({ profile = "dev", deploy = null } = {}) { runAfter: ["gitops-promote"], workspaces: [{ name: "source", workspace: "source" }], taskSpec: { - params: [{ name: "revision" }, { name: "runtime-namespace" }, { name: "gitops-target" }, { name: "argo-application" }, { name: "timeout-ms" }], + params: [{ name: "revision" }, { name: "runtime-namespace" }, { name: "gitops-target" }, { name: "timeout-ms" }], workspaces: [{ name: "source" }], steps: [{ name: "runtime-ready", @@ -458,8 +458,7 @@ function runtimeReadyTask({ profile = "dev", deploy = null } = {}) { env: [ ...proxyEnv(), { name: "HWLAB_RUNTIME_NAMESPACE", value: "$(params.runtime-namespace)" }, - { name: "HWLAB_GITOPS_TARGET", value: "$(params.gitops-target)" }, - { name: "HWLAB_ARGO_APPLICATION", value: "$(params.argo-application)" } + { name: "HWLAB_GITOPS_TARGET", value: "$(params.gitops-target)" } ], script: runtimeReadyScript() }] @@ -468,7 +467,6 @@ function runtimeReadyTask({ profile = "dev", deploy = null } = {}) { { name: "revision", value: "$(params.revision)" }, { name: "runtime-namespace", value: namespaceNameForProfile(profile, deploy) }, { name: "gitops-target", value: gitopsTargetForProfile(profile) }, - { name: "argo-application", value: argoApplicationName(profile) }, { name: "timeout-ms", value: "$(params.runtime-ready-timeout-ms)" } ] };