fix: clean legacy runtime lane argo apps

This commit is contained in:
Codex
2026-06-08 16:09:06 +00:00
parent 1c5f88464d
commit aadbf176ba
3 changed files with 30 additions and 4 deletions
+24 -2
View File
@@ -3005,6 +3005,11 @@ function cleanupV02RenderDir(renderDir: string): CommandJsonResult {
return cleanupRuntimeLaneRenderDir(V02_LANE_SPEC, renderDir);
}
function legacyRuntimeLaneArgoApplications(spec: HwlabRuntimeLaneSpec): string[] {
if (spec.lane === "v02") return [];
return [`hwlab-g14-${spec.lane}`].filter((name) => name !== spec.app);
}
function applyRuntimeLaneControlPlaneFiles(spec: HwlabRuntimeLaneSpec, renderDir: string, dryRun: boolean, timeoutSeconds: number): CommandJsonResult {
const namespaceFile = `${renderDir}/${spec.runtimeRenderDir}/namespace.yaml`;
const rbacFile = `${renderDir}/${spec.tektonDir}/rbac.yaml`;
@@ -3012,6 +3017,7 @@ function applyRuntimeLaneControlPlaneFiles(spec: HwlabRuntimeLaneSpec, renderDir
const projectFile = `${renderDir}/argocd/project.yaml`;
const applicationFile = `${renderDir}/argocd/${spec.argoApplicationFile}`;
const resourceFiles = [namespaceFile, rbacFile, pipelineFile, projectFile, applicationFile];
const legacyApplications = legacyRuntimeLaneArgoApplications(spec);
const serverSideArgs = [
"kubectl",
"apply",
@@ -3044,12 +3050,28 @@ function applyRuntimeLaneControlPlaneFiles(spec: HwlabRuntimeLaneSpec, renderDir
].map(shellQuote).join(" "),
].join("\n")
: `exec ${serverSideArgs.map(shellQuote).join(" ")}`;
const cleanupCommands = legacyApplications.map((name) => [
"kubectl",
"delete",
"application",
"-n",
"argocd",
name,
"--ignore-not-found=true",
...(dryRun ? ["--dry-run=server", "-o", "name"] : []),
].map(shellQuote).join(" "));
const script = cleanupCommands.length > 0
? ["set -eu", shellCommand.replace(/^exec /, ""), ...cleanupCommands].join("\n")
: shellCommand;
const visibleCommand = cleanupCommands.length > 0
? ["bun", "scripts/cli.ts", "ssh", `${G14_PROVIDER}:k3s`, "script", "--", script]
: command;
return runG14K3sRemoteAsync({
script: shellCommand,
script,
timeoutSeconds,
label: `${spec.lane}-control-plane-apply`,
token: runtimeLaneRenderToken(),
command,
command: visibleCommand,
});
}