Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(minikube): resolve the verify tag from what the cluster acquired
Jose Ramirezc6e74045642a
diff --git a/scripts/minikube/build-images.sh b/scripts/minikube/build-images.shindex 6a15c7bf7..21c191af1 100755--- a/scripts/minikube/build-images.sh+++ b/scripts/minikube/build-images.sh@@ -129,7 +129,8 @@ case "$IMAGE_SOURCE" in*) echo "Unknown IMAGE_SOURCE: '${IMAGE_SOURCE}' (expected: ghcr | local)" >&2; exit 1 ;;esacGHCR_NAMESPACE="ghcr.io/evenfire-ai"-GHCR_COMPONENT="${PROJECT_DIR}/deploy/components/ghcr-images/kustomization.yaml"+# The committed pin is NOT read here. resolve_ghcr_tag below delegates to+# image-mode.sh, which owns that read along with the recorded-tag precedence.# Written by this script's manifest writer and by pull-images.sh; read back by# --verify-only. Declared here, not next to the writer at the bottom, because@@ -163,20 +164,21 @@ if [ "${MINIKUBE_SEED_PROFILE:-}" = "e2e" ]; thenINCLUDE_E2E_FIXTURES=truefi-# The effective ghcr tag: MINIKUBE_IMAGE_TAG if set (a render-time operator-# lever), otherwise the committed pin, which is the single source of truth.+# The effective ghcr tag: the explicit MINIKUBE_IMAGE_TAG override, else the tag+# the last acquisition RECORDED for this cluster, else the committed pin.+#+# The recorded tag is not optional here. It is the imageSource bug above with a+# different field: `MINIKUBE_IMAGE_TAG=latest make minikube-setup` is the+# documented bootstrap while no release tag exists on ghcr, and the NEXT shell+# has no such variable. Resolving the committed pin there reported+# "23 of 23 images missing!" against a cluster holding every :latest ref, and+# told the operator to pull a tag that is not published at all.+#+# image_mode_tag applies exactly that precedence and is the resolver+# pre-gate-sync.sh already uses; a second copy of the precedence in this file is+# what let the two disagree, so this delegates instead of reimplementing it.resolve_ghcr_tag() {- if [ -n "${MINIKUBE_IMAGE_TAG:-}" ]; then- printf '%s' "$MINIKUBE_IMAGE_TAG"- return 0- fi- [ -f "$GHCR_COMPONENT" ] || { echo "ghcr component not found at ${GHCR_COMPONENT}" >&2; exit 1; }- local tags- tags="$(sed -n 's/^[[:space:]]*newTag:[[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' "$GHCR_COMPONENT" | sort -u)"- [ -n "$tags" ] || { echo "no newTag: line in ${GHCR_COMPONENT}" >&2; exit 1; }- [ "$(printf '%s\n' "$tags" | wc -l | tr -d ' ')" = "1" ] \- || { echo "mixed newTag values in ${GHCR_COMPONENT}: $(printf '%s ' $tags)" >&2; exit 1; }- printf '%s' "$tags"+ image_mode_tag "$PROJECT_DIR"}for arg in "$@"; do@@ -450,7 +452,27 @@ if [ "$VERIFY_ONLY" = true ]; thenGHCR_TAG=""if [ "$IMAGE_SOURCE" = ghcr ]; then- GHCR_TAG="$(resolve_ghcr_tag)"+ if ! GHCR_TAG="$(resolve_ghcr_tag)"; then+ err "could not resolve the ghcr tag this cluster runs"+ exit 1+ fi+ # A tagless ref (ghcr.io/evenfire-ai/control-api:) matches nothing in the+ # daemon, so an empty resolution would report every image missing rather+ # than reporting that the resolution failed.+ if [ -z "$GHCR_TAG" ]; then+ err "resolved an empty ghcr tag; refusing to verify tagless image refs"+ exit 1+ fi+ # Same shape as VERIFY_SOURCE_ORIGIN above: the operator has to be able to+ # tell a recorded coordinate from the committed pin when the answer surprises+ # them.+ VERIFY_TAG_ORIGIN="deploy/components/ghcr-images (the committed pin)"+ if [ -n "${MINIKUBE_IMAGE_TAG:-}" ]; then+ VERIFY_TAG_ORIGIN="the MINIKUBE_IMAGE_TAG environment variable"+ elif [ -n "$(recorded_image_tag)" ]; then+ VERIFY_TAG_ORIGIN="deploy/minikube/.image-manifest.json"+ fi+ log "tag ${GHCR_TAG} from ${VERIFY_TAG_ORIGIN}"if [ "$INCLUDE_E2E_FIXTURES" = false ]; thenlog "excluding the E2E-only fixtures; 'make minikube-setup-e2e' builds them (SEED_PROFILE=e2e to check them)"fidiff --git a/scripts/tests/test-minikube-verify-images.sh b/scripts/tests/test-minikube-verify-images.shindex 081fb056e..29ba13862 100755--- a/scripts/tests/test-minikube-verify-images.sh+++ b/scripts/tests/test-minikube-verify-images.sh@@ -44,11 +44,15 @@ all_local_refs() {}).catch(e => { console.error(e.message); process.exit(1) })'}-all_ghcr_refs() {+all_ghcr_refs_at_tag() {node -e 'import("'"$REPO_ROOT"'/scripts/release/images-manifest.mjs").then(m => {- for (const i of m.pullInGhcrMode()) console.log(`ghcr.io/evenfire-ai/${i.name}:'"$PIN_TAG"'`)- }).catch(e => { console.error(e.message); process.exit(1) })'+ for (const i of m.pullInGhcrMode()) console.log(`ghcr.io/evenfire-ai/${i.name}:${process.argv[1]}`)+ }).catch(e => { console.error(e.message); process.exit(1) })' "$1"+}++all_ghcr_refs() {+ all_ghcr_refs_at_tag "$PIN_TAG"}# The payload the stubbed `minikube image ls --format=json` serves. Each ref is@@ -111,12 +115,18 @@ prepare_repo() {}# $2 is the newline-separated set of refs the stubbed daemon holds.+#+# MINIKUBE_IMAGE_TAG is passed EXPLICITLY, defaulting to empty, so a value+# exported in the developer's shell (the documented `MINIKUBE_IMAGE_TAG=latest`+# bootstrap leaves one behind) cannot make a case pass for the wrong reason.+# Cases that want the override set TEST_IMAGE_TAG.run_verify() {local d=$1 present=$2; shift 2write_present_json "$d/present.json" "$present"PATH="$d/bin:$PATH" \TEST_LOG_FILE="$d/ops.log" \TEST_PRESENT_JSON="$d/present.json" \+ MINIKUBE_IMAGE_TAG="${TEST_IMAGE_TAG:-}" \bash "$d/repo/scripts/minikube/build-images.sh" --verify-only "$@" 2>&1}@@ -335,6 +345,129 @@ assert_an_only_build_carries_the_recorded_mode_forward() {rm -rf "$d"}+# ---------------------------------------------------------------------------+# The recorded TAG, not only the recorded mode+# ---------------------------------------------------------------------------+#+# The imageSource fix left imageTag resolving from MINIKUBE_IMAGE_TAG or the+# committed pin only. `MINIKUBE_IMAGE_TAG=latest make minikube-setup` is the+# documented bootstrap (no release tag is published yet), and the NEXT shell has+# no such variable: `make minikube-verify-images` then resolved the pin and+# reported "23 of 23 images missing!" on a cluster holding every :latest ref,+# advising a pull of a tag that is 404 on ghcr.+#+# Every case below declares the daemon's contents at ONE tag, so resolving the+# other one fails it. That is what makes them survive a semantic mutation:+# swapping the precedence changes which refs are looked up, not just which+# identifier is read.++assert_the_recorded_tag_is_verified_when_the_shell_has_no_override() {+ local d out rc+ d="$(mktemp -d)"+ prepare_repo "$d"+ write_recorded_manifest "$d" \+ '{"generated":"x","profile":"clerum-test","imageSource":"ghcr","imageTag":"latest","images":{}}'+ # The daemon holds ONLY :latest -- exactly what the bootstrap pull put there.+ out="$(run_verify "$d" "$(all_ghcr_refs_at_tag latest)")"; rc=$?+ if [ "$rc" -eq 0 ] \+ && grep -q 'ghcr\.io/evenfire-ai/control-api:latest' <<< "$out" \+ && ! grep -q "ghcr\.io/evenfire-ai/control-api:${PIN_TAG}" <<< "$out" \+ && grep -q 'All .* images present' <<< "$out"; then+ pass "the recorded imageTag is verified when the shell carries no MINIKUBE_IMAGE_TAG"+ else+ fail "expected a clean verify against :latest refs; got rc=$rc: $out"+ fi+ rm -rf "$d"+}++# The override is a render-time operator lever and must still win: a developer+# who exports a tag is asking to look at THAT release, not at the last one the+# cluster acquired.+assert_an_explicit_tag_override_still_beats_the_recorded_tag() {+ local d out rc+ d="$(mktemp -d)"+ prepare_repo "$d"+ write_recorded_manifest "$d" \+ '{"generated":"x","profile":"clerum-test","imageSource":"ghcr","imageTag":"latest","images":{}}'+ # The daemon holds ONLY v9.9.9, so honouring the recorded 'latest' fails here.+ out="$(TEST_IMAGE_TAG=v9.9.9 run_verify "$d" "$(all_ghcr_refs_at_tag v9.9.9)")"; rc=$?+ if [ "$rc" -eq 0 ] \+ && grep -q 'ghcr\.io/evenfire-ai/control-api:v9\.9\.9' <<< "$out" \+ && ! grep -q 'control-api:latest' <<< "$out"; then+ pass "an explicit MINIKUBE_IMAGE_TAG still outranks the recorded tag"+ else+ fail "expected the v9.9.9 override to be verified; got rc=$rc: $out"+ fi+ rm -rf "$d"+}++# Nothing recorded a tag (a cluster pulled at the pin, or a manifest predating+# the key), so the committed pin is the only coordinate left.+assert_the_committed_pin_is_the_fallback_when_no_tag_is_recorded() {+ local d out rc+ d="$(mktemp -d)"+ prepare_repo "$d"+ write_recorded_manifest "$d" \+ '{"generated":"x","profile":"clerum-test","imageSource":"ghcr","images":{}}'+ out="$(run_verify "$d" "$(all_ghcr_refs_at_tag "$PIN_TAG")")"; rc=$?+ if [ "$rc" -eq 0 ] \+ && grep -q "ghcr\.io/evenfire-ai/control-api:${PIN_TAG}" <<< "$out" \+ && grep -q 'All .* images present' <<< "$out"; then+ pass "the committed pin is used when the manifest records no imageTag"+ else+ fail "expected the pin ${PIN_TAG} to be verified; got rc=$rc: $out"+ fi+ rm -rf "$d"+}++# The remedy is part of the diagnostic. "make minikube-pull-images (tag+# v0.6.0)" on a cluster running :latest sends the operator at a 404.+assert_the_pull_remedy_names_the_tag_the_cluster_actually_runs() {+ local d out rc present+ d="$(mktemp -d)"+ prepare_repo "$d"+ write_recorded_manifest "$d" \+ '{"generated":"x","profile":"clerum-test","imageSource":"ghcr","imageTag":"latest","images":{}}'+ present="$(all_ghcr_refs_at_tag latest | grep -v '^ghcr.io/evenfire-ai/control-api:latest$')"+ out="$(run_verify "$d" "$present")"; rc=$?+ if [ "$rc" -ne 0 ] \+ && grep -q 'MISSING: ghcr\.io/evenfire-ai/control-api:latest' <<< "$out" \+ && grep -q 'tag latest' <<< "$out" \+ && ! grep -q "tag ${PIN_TAG}" <<< "$out"; then+ pass "the pull remedy names the recorded tag, not the committed pin"+ else+ fail "expected a remedy naming 'latest'; got rc=$rc: $out"+ fi+ rm -rf "$d"+}++# Where the tag came from is printed, so an operator who disagrees with the+# answer can see which of the three inputs produced it.+assert_the_tag_origin_is_reported() {+ local d recorded pinned overridden problems=""+ d="$(mktemp -d)"+ prepare_repo "$d"+ write_recorded_manifest "$d" \+ '{"generated":"x","profile":"clerum-test","imageSource":"ghcr","imageTag":"latest","images":{}}'+ recorded="$(run_verify "$d" "$(all_ghcr_refs_at_tag latest)")"+ overridden="$(TEST_IMAGE_TAG=v9.9.9 run_verify "$d" "$(all_ghcr_refs_at_tag v9.9.9)")"+ write_recorded_manifest "$d" \+ '{"generated":"x","profile":"clerum-test","imageSource":"ghcr","images":{}}'+ pinned="$(run_verify "$d" "$(all_ghcr_refs_at_tag "$PIN_TAG")")"+ grep -q 'tag latest from deploy/minikube/.image-manifest.json' <<< "$recorded" \+ || problems+="recorded tag origin not reported; "+ grep -q 'tag v9.9.9 from the MINIKUBE_IMAGE_TAG environment variable' <<< "$overridden" \+ || problems+="override origin not reported; "+ grep -q "tag ${PIN_TAG} from deploy/components/ghcr-images" <<< "$pinned" \+ || problems+="pin origin not reported; "+ if [ -z "$problems" ]; then+ pass "the verify banner names the tag and where it came from"+ else+ fail "$problems"+ fi+ rm -rf "$d"+}+# ---------------------------------------------------------------------------# FINDING B -- the E2E-only fixtures# ---------------------------------------------------------------------------@@ -533,6 +666,11 @@ assert_a_pulled_cluster_is_told_to_pull_at_the_named_tagassert_the_puller_records_ghcr_and_the_verifier_reads_it_backassert_a_full_build_records_local_and_the_verifier_reads_it_backassert_an_only_build_carries_the_recorded_mode_forward+assert_the_recorded_tag_is_verified_when_the_shell_has_no_override+assert_an_explicit_tag_override_still_beats_the_recorded_tag+assert_the_committed_pin_is_the_fallback_when_no_tag_is_recorded+assert_the_pull_remedy_names_the_tag_the_cluster_actually_runs+assert_the_tag_origin_is_reportedassert_the_default_ghcr_verify_passes_without_the_e2e_fixturesassert_the_verify_set_never_demands_a_registry_distributed_mcp_serverassert_the_e2e_seed_profile_puts_the_fixtures_back