fix: guard D601 k3s control plane

This commit is contained in:
Codex
2026-05-23 12:57:23 +00:00
parent a20d041c23
commit 6c44f66289
9 changed files with 47 additions and 8 deletions
+3 -1
View File
@@ -3027,7 +3027,7 @@ function rollbackInfo(spec: ArtifactConsumerSpec, target: ArtifactConsumerTarget
serviceId: spec.serviceId,
environment,
currentCommit: commit,
discovery: `kubectl -n ${target.k3s?.namespace} rollout history deployment/${target.k3s?.deploymentName} && kubectl -n ${target.k3s?.namespace} get deployment ${target.k3s?.deploymentName} -o jsonpath='{.metadata.annotations.unidesk\\.ai/deploy-previous-commit}'`,
discovery: `KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl -n ${target.k3s?.namespace} rollout history deployment/${target.k3s?.deploymentName} && KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl -n ${target.k3s?.namespace} get deployment ${target.k3s?.deploymentName} -o jsonpath='{.metadata.annotations.unidesk\\.ai/deploy-previous-commit}'`,
commandShape: `bun scripts/cli.ts deploy apply --env ${environment} --service ${spec.serviceId} --commit <previous-full-sha>`,
note: "Rollback is exposed as the same artifact consumer pointed at a previous commit-pinned image that still exists in D601 registry.",
};
@@ -3100,6 +3100,8 @@ function d601K3sArtifactDeployScript(options: ArtifactRegistryOptions, spec: Art
"command -v kubectl >/dev/null",
"command -v ctr >/dev/null",
"test -S /run/k3s/containerd/containerd.sock",
"test \"$(kubectl get nodes -o jsonpath='{.items[*].metadata.name}')\" = \"d601\"",
"! kubectl config current-context | grep -Eq 'docker-desktop|desktop-control-plane'",
`curl -fsSI -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' ${shellQuote(`http://127.0.0.1:${options.port}/v2/${spec.registryRepository}/manifests/${commit}`)} >/dev/null`,
"docker pull -q \"$registry_image\" >/dev/null",
"label_commit=$(docker image inspect \"$registry_image\" --format '{{ index .Config.Labels \"unidesk.ai/source-commit\" }}')",
+7 -2
View File
@@ -216,9 +216,14 @@ function validateDatabaseUrl(url: string): { ok: boolean; url: string; reason: s
}
function kubectlDryRun(manifestPath: string): unknown {
const result = runCommand(["kubectl", "apply", "--dry-run=client", "--validate=false", "-f", manifestPath], repoRoot, { timeoutMs: 60_000 });
const kubeconfig = "/etc/rancher/k3s/k3s.yaml";
const result = runCommand(["kubectl", "apply", "--dry-run=client", "--validate=false", "-f", manifestPath], repoRoot, {
timeoutMs: 60_000,
env: { ...process.env, KUBECONFIG: kubeconfig },
});
return {
command: result.command,
command: [`KUBECONFIG=${kubeconfig}`, ...result.command],
kubeconfig,
exitCode: result.exitCode,
signal: result.signal,
timedOut: result.timedOut,