Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(minikube): keep the empty local imageTag in place when the T2 planner splits marker values

Alfredo Lopez3f610305b1e7
diff --git a/scripts/minikube/t2-common.sh b/scripts/minikube/t2-common.sh
index 5b3bb32db..d174f1aa8 100755
--- a/scripts/minikube/t2-common.sh
+++ b/scripts/minikube/t2-common.sh
@@ -467,7 +467,9 @@ if data.get("gitHead") != sys.argv[3]:
raise SystemExit("head")
if not data.get("imagesGeneratedAt"):
raise SystemExit("missing:imagesGeneratedAt")
-print("\t".join([
+# \x1f, not a tab: a local build has an empty imageTag, and `read` collapses
+# consecutive IFS whitespace, which would shift the next field into its slot.
+print("\x1f".join([
data.get("clusterFingerprint", ""),
data.get("imageSource", ""),
data.get("imageTag", ""),
@@ -496,7 +498,7 @@ PY
return 1
fi
local marker_fingerprint source_fingerprint
- IFS=$'\t' read -r marker_fingerprint _ <<< "$marker_values"
+ IFS=$'\x1f' read -r marker_fingerprint _ <<< "$marker_values"
# A marker for this HEAD is current only while the working tree still hashes
# to the digest it was stamped with; NP-08 recomputes the same digest.
if ! source_fingerprint="$(pre_gate_marker_cluster_fingerprint "$T2_PROJECT_DIR")"; then
@@ -515,7 +517,7 @@ PY
return 1
fi
T2_MARKER_MATCHES_HEAD=true
- IFS=$'\t' read -r T2_CLUSTER_FINGERPRINT T2_IMAGE_SOURCE T2_IMAGE_TAG \
+ IFS=$'\x1f' read -r T2_CLUSTER_FINGERPRINT T2_IMAGE_SOURCE T2_IMAGE_TAG \
T2_MARKER_IMAGES_GENERATED_AT <<< "$marker_values"
}
@@ -555,7 +557,8 @@ if source == "local":
digest = re.compile(r"^sha256:[0-9a-fA-F]{64}$")
if any(not isinstance(name, str) or not name or not isinstance(value, str) or not digest.fullmatch(value) for name, value in images.items()):
raise SystemExit("local-digests")
-print(source + "\t" + tag + "\t" + generated)
+# \x1f for the same reason as the marker values: tag is empty for local builds.
+print(source + "\x1f" + tag + "\x1f" + generated)
PY
)"; then
if [ "$T2_BOOTSTRAP_REQUIRED" = true ]; then
@@ -567,7 +570,7 @@ PY
t2_fail IMAGE_MANIFEST_MISMATCH 'image manifest is invalid or incomplete for its image source'
fi
local manifest_source manifest_tag manifest_generated
- IFS=$'\t' read -r manifest_source manifest_tag manifest_generated <<< "$manifest_values"
+ IFS=$'\x1f' read -r manifest_source manifest_tag manifest_generated <<< "$manifest_values"
if { [ -n "$T2_IMAGE_SOURCE" ] && [ "$manifest_source" != "$T2_IMAGE_SOURCE" ]; } ||
{ [ -n "$T2_IMAGE_TAG" ] && [ "$manifest_tag" != "$T2_IMAGE_TAG" ]; }; then
T2_NEXT_COMMAND="MINIKUBE_PROFILE=$T2_PROFILE make minikube-setup-local"
diff --git a/scripts/tests/test-minikube-t2-scenarios.sh b/scripts/tests/test-minikube-t2-scenarios.sh
index fe9494676..0d9950e18 100755
--- a/scripts/tests/test-minikube-t2-scenarios.sh
+++ b/scripts/tests/test-minikube-t2-scenarios.sh
@@ -350,15 +350,17 @@ stamp_manifest="$tmp/stamp-image-manifest.json"
printf '{"generated":"new-generated","imageSource":"local","imageTag":"test","images":{"clerum/control-api:test":"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}}\n' >"$stamp_manifest"
stamp_fp="$(source_fingerprint)"
[[ "$stamp_fp" =~ ^[0-9a-f]{40}$ ]] || fail "fixture source fingerprint is not a digest: $stamp_fp"
+# Usage: stamp_plan <marker imagesGeneratedAt> [manifest] [marker imageTag]
stamp_plan() {
+ local marker_tag="${3-test}"
env T2_PROJECT_DIR="$repo" MINIKUBE_PROFILE="$profile" \
T2_CONTEXT="$profile" CONTROL_API_REAL_PG_CONTEXT="$profile" \
T2_PROFILE_ROOT="$tmp/profiles" T2_PROFILE_ENV="$profile_root/profile.env" \
T2_PORTS_ENV="$profile_root/ports.env" T2_REQUIRED_DEPLOYMENTS=gfs/gfsc-reader \
T2_BRANCH=feat/scenario T2_HEAD="$feature_sha" T2_ORIGIN_DEV="$base_sha" \
T2_LOCK_ROOT="$tmp/locks" T2_EVIDENCE_ROOT="$tmp/evidence" \
- T2_IMAGE_MANIFEST="$stamp_manifest" \
- FAKE_MARKER='{"data":{"clusterFingerprint":"'"$stamp_fp"'","gitHead":"'"$feature_sha"'","worktreeId":"worktree-a","imageSource":"local","imageTag":"test","imagesGeneratedAt":"'"$1"'"}}' \
+ T2_IMAGE_MANIFEST="${2:-$stamp_manifest}" \
+ FAKE_MARKER='{"data":{"clusterFingerprint":"'"$stamp_fp"'","gitHead":"'"$feature_sha"'","worktreeId":"worktree-a","imageSource":"local","imageTag":"'"$marker_tag"'","imagesGeneratedAt":"'"$1"'"}}' \
bash -c 'source "$1"; T2_WORKTREE_ID=worktree-a; T2_HEAD="$3"; T2_ORIGIN_DEV="$2"; T2_PLAN_MODE=true; T2_BOOTSTRAP_REQUIRED=false; t2_kc(){ printf "%s" "$FAKE_MARKER"; }; t2_marker_check; t2_image_check; t2_classify_transition; printf "%s|%s" "$T2_PLAN_STATE" "$T2_PLAN_REASON"' bash "$COMMON" "$base_sha" "$feature_sha"
}
stamp_state="$(stamp_plan old-generated)"
@@ -373,6 +375,26 @@ stamp_current_state="$(stamp_plan new-generated)"
[ "${stamp_current_state%%|*}" = already-synced ] ||
fail "a marker matching HEAD, source and image stamp selected $stamp_current_state"
+# A local build writes an empty imageTag into both the manifest and the marker.
+# The planner splits their values on tabs; the empty tag must stay an empty
+# field instead of shifting the generated stamp into the tag slot, which turned
+# a changed image stamp into IMAGE_MANIFEST_MISMATCH before any transition.
+local_stamp_manifest="$tmp/local-stamp-image-manifest.json"
+printf '{"generated":"new-generated","imageSource":"local","imageTag":"","images":{"clerum/control-api:test":"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"}}\n' >"$local_stamp_manifest"
+local_stamp_state="$(stamp_plan old-generated "$local_stamp_manifest" "" 2>&1)" ||
+ fail "a changed image stamp on a local build (empty imageTag) stopped the planner: $local_stamp_state"
+case "$local_stamp_state" in
+ targeted-sync*|full-reconcile*) ;;
+ *) fail "a changed image stamp on a local build (empty imageTag) selected: $local_stamp_state" ;;
+esac
+# Twin: the same empty-tag marker with the current stamp is already-synced.
+local_stamp_current_state="$(stamp_plan new-generated "$local_stamp_manifest" "" 2>&1)" ||
+ fail "an empty-tag marker matching HEAD, source and image stamp stopped the planner: $local_stamp_current_state"
+case "$local_stamp_current_state" in
+ 'already-synced|'*) ;;
+ *) fail "an empty-tag marker matching HEAD, source and image stamp selected: $local_stamp_current_state" ;;
+esac
+
# A bootstrapped profile with an unready required deployment must not stop
# the orchestrator planner before a transition exists (PROFILE_UNHEALTHY was
# the multi-script loop): planner mode selects full-reconcile and names the