From 050a4de23508cb40b204e946a8a7c486e1642d19 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 02:00:20 +0900 Subject: [PATCH] fix(validate): render the drift check from a clean working-tree copy In a long-lived checkout the observability renderer finds an ignored .helm/charts/- cache left by an earlier render and refuses ("exact chart cache already exists"), so live-drift-check.sh fails with exit 2 in /home/donghyeon/workspace/platform, the path the runbooks use. When run inside a git working tree, copy the tracked and untracked (not ignored, not deleted) files to the drift work directory and render from there. Local edits are still checked; ignored caches are not carried over. Outside a git tree (the daily timer renders a git archive of origin/main) nothing changes. Also accept the one drift this exposed: the kube-prometheus-stack PrometheusRule still has the two Kubelet certificate alerts that PR #6 disabled in values; it goes away when the observability core is re-applied in the restart window (until 2026-11-30). Risk: read-only, as before. The copy is removed with the work directory. Verification (desktop, fresh clone of main 8b019d2 with an ignored services/observability/tempo/.helm/charts/tempo-2.2.3 created): - old script: "REJECT: exact chart cache already exists", exit 2. - new script as an uncommitted edit in that clone: SUMMARY drift=1 accepted=12 (the PrometheusRule above), exit 1. - new script from a git archive export, as the timer runs it: same summary. --- scripts/validate/live-drift-accepted.txt | 1 + scripts/validate/live-drift-check.sh | 29 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/scripts/validate/live-drift-accepted.txt b/scripts/validate/live-drift-accepted.txt index cd416e9..4ae432c 100644 --- a/scripts/validate/live-drift-accepted.txt +++ b/scripts/validate/live-drift-accepted.txt @@ -12,3 +12,4 @@ Keycloak keycloak keycloak 2026-11-30 이미지 digest·startOptimized false·pl Deployment gitea gitea 2026-11-30 priorityClassName platform-critical(Gitea 재시작). 재시작 창에 apply-gitea-oidc.sh로 적용한다. StatefulSet observability loki 2026-11-30 priorityClassName platform-low(Loki 재시작). 재시작 창에 관측 core 적용으로. StatefulSet observability tempo 2026-11-30 priorityClassName platform-low(Tempo 재시작). 재시작 창에 관측 core 적용으로. +PrometheusRule observability observability-core-kube-pr-kubernetes-system-kubelet 2026-11-30 Kubelet 인증서 경보 둘을 values에서 껐다(PR #6). 관측 core를 다시 적용하면 사라진다(재시작 창 2단계). diff --git a/scripts/validate/live-drift-check.sh b/scripts/validate/live-drift-check.sh index 4e85a2d..6334d59 100644 --- a/scripts/validate/live-drift-check.sh +++ b/scripts/validate/live-drift-check.sh @@ -64,10 +64,29 @@ die() { work="$(mktemp -d /tmp/platform-drift.XXXXXX)"; made_dirs+=("$work") mkdir -p "$work/in" "$work/out" +# Render from a clean copy when run inside a git working tree. The observability +# renderer refuses to run when an ignored chart cache (.helm/) is left over from an +# earlier render, which happens in long-lived checkouts. The copy keeps tracked and +# untracked-but-not-ignored files, so local edits are still checked. +SOURCE_ROOT="$REPOSITORY_ROOT" +if git -C "$REPOSITORY_ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then + SOURCE_ROOT="$work/src" + mkdir -p "$SOURCE_ROOT" + python3 -I - "$REPOSITORY_ROOT" <<'PY' | tar -C "$REPOSITORY_ROOT" --null -T - -cf - | tar -x -C "$SOURCE_ROOT" || die "could not copy the working tree" +import subprocess, sys +root = sys.argv[1] +def ls(*args): + out = subprocess.run(["git", "-C", root, "ls-files", "-z", *args], check=True, capture_output=True).stdout + return [p for p in out.decode().split("\0") if p] +keep = set(ls("--cached", "--others", "--exclude-standard")) - set(ls("--deleted")) +sys.stdout.write("\0".join(sorted(keep)) + "\0") +PY +fi + render_root() { local script="$1" prefix="$2" dir dir="$(mktemp -d "/tmp/${prefix}.XXXXXX")"; made_dirs+=("$dir") - bash "$REPOSITORY_ROOT/scripts/validate/${script}" --verified-output-dir "$dir" \ + bash "$SOURCE_ROOT/scripts/validate/${script}" --verified-output-dir "$dir" \ >"$work/${script}.log" 2>&1 || { tail -5 "$work/${script}.log" >&2; die "${script} failed"; } printf '%s\n' "$dir" } @@ -86,10 +105,10 @@ declare -a inputs=( for f in "$phase2"/*.yaml "$admin"/*.yaml; do inputs+=("$f"); done # Live Traefik is the trust overlay (infrastructure/networking/traefik/README.md). -kubectl kustomize "$REPOSITORY_ROOT/infrastructure/networking/traefik/overlays/trust" >"$work/traefik-trust.yaml" || die "traefik render failed" -kubectl kustomize "$REPOSITORY_ROOT/services/tenants/techlog" >"$work/tenant-techlog.yaml" || die "tenant render failed" -kubectl kustomize "$REPOSITORY_ROOT/services/priority-classes" >"$work/priority-classes.yaml" || die "priority class render failed" -kubectl kustomize "$REPOSITORY_ROOT/infrastructure/networking/keycloak" >"$work/keycloak-network-policies.yaml" || die "keycloak policy render failed" +kubectl kustomize "$SOURCE_ROOT/infrastructure/networking/traefik/overlays/trust" >"$work/traefik-trust.yaml" || die "traefik render failed" +kubectl kustomize "$SOURCE_ROOT/services/tenants/techlog" >"$work/tenant-techlog.yaml" || die "tenant render failed" +kubectl kustomize "$SOURCE_ROOT/services/priority-classes" >"$work/priority-classes.yaml" || die "priority class render failed" +kubectl kustomize "$SOURCE_ROOT/infrastructure/networking/keycloak" >"$work/keycloak-network-policies.yaml" || die "keycloak policy render failed" inputs+=("$work/traefik-trust.yaml" "$work/tenant-techlog.yaml" "$work/priority-classes.yaml" "$work/keycloak-network-policies.yaml") n=0