fix: guard D601 k3s control plane
This commit is contained in:
@@ -150,6 +150,8 @@ trap 'code=$?; if [ "$code" -ne 0 ] && [ ! -f "$result_json" ]; then write_resul
|
||||
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
kubectl get nodes >/dev/null
|
||||
test "$(kubectl get nodes -o jsonpath='{.items[*].metadata.name}')" = "d601"
|
||||
! kubectl config current-context | grep -Eq 'docker-desktop|desktop-control-plane'
|
||||
|
||||
log_json runner_started run_id "$run_id" manifest_commit "$manifest_commit"
|
||||
kubectl get pipeline/unidesk-dev-namespace-e2e -n unidesk-ci >/dev/null
|
||||
|
||||
@@ -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\" }}')",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user