Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(minikube): pull published images instead of building them
Jose Ramirezc94fb5ffeea2
diff --git a/.github/workflows/ci-public.yml b/.github/workflows/ci-public.ymlindex 4e108b9a3..e3d042138 100644--- a/.github/workflows/ci-public.yml+++ b/.github/workflows/ci-public.yml@@ -363,6 +363,9 @@ jobs:- name: Test the ghcr render guardrun: bash scripts/tests/test-ghcr-render-guard.sh+ - name: Test the minikube image puller+ run: bash scripts/tests/test-minikube-pull-images.sh+- name: Test release image resolutionrun: bash scripts/tests/test-resolve-release-images.shdiff --git a/scripts/minikube/pull-images.sh b/scripts/minikube/pull-images.shnew file mode 100755index 000000000..067c9a762--- /dev/null+++ b/scripts/minikube/pull-images.sh@@ -0,0 +1,250 @@+#!/usr/bin/env bash+# ======================================================================+# Pull Published Images into Minikube (IMAGE_SOURCE=ghcr)+# ======================================================================+#+# Pulls every pull_in_ghcr_mode image (deploy/images.json:+# published && deployed_to_minikube) from ghcr.io/evenfire-ai at the pinned+# release tag, in parallel, then aliases each one to its local clerum/* ref.+#+# This is the default path for `make minikube-setup`. Its local-build+# counterpart is scripts/minikube/build-images.sh.+#+# Usage:+# MINIKUBE_PROFILE=clerum-test ./scripts/minikube/pull-images.sh [--only=<svc>]+#+# Env:+# MINIKUBE_IMAGE_TAG Override the committed pin (render-time only,+# never committed). Use `latest` to exercise the+# pull path before a release tag exists.+# MINIKUBE_PROFILE Target profile (default: clerum-test)+# MINIKUBE_MULTI_NODE true -> pull on the host + `minikube image load`+# MINIKUBE_PULL_PARALLELISM Concurrent pulls (default: 6)+#+# Two behaviours here are load-bearing; do not "optimize" them away:+#+# 1. It RE-PULLS a tag already present in the daemon. A pre-gate shadow build+# (scripts/minikube/pre-gate-sync.sh) is deliberately tagged with the exact+# ghcr ref so IfNotPresent picks it up. Skipping present tags would let+# that local build survive across setups indefinitely and invisibly, and a+# gate would keep testing code that was never deployed.+#+# 2. It ALIASES each ghcr ref to clerum/<local_name>:<local_tag>. Six+# pull_in_ghcr_mode images have no row in the minikube overlay and are+# never rewritten by the ghcr component -- mcp-host-slim, mcp-host-full,+# airtable-mcp-server, web-search-mcp, mock-mcp-server,+# mock-stdio-mcp-server. They are consumed under their LOCAL names by+# McpServer CRD instances applied outside the overlay+# (deploy/overlays/minikube/instances-e2e/airtable-server.yaml) and by the+# E2E scripts under scripts/e2e/. A `docker tag` is a pointer; dropping it+# breaks those paths in ghcr mode only, which is the worst place to find+# out.+# ======================================================================++set -euo pipefail++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+PROJECT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"++PROFILE="${MINIKUBE_PROFILE:-clerum-test}"+MINIKUBE_MULTI_NODE="${MINIKUBE_MULTI_NODE:-false}"+PULL_PARALLELISM="${MINIKUBE_PULL_PARALLELISM:-6}"+GHCR_NAMESPACE="ghcr.io/evenfire-ai"+COMPONENT="${PROJECT_DIR}/deploy/components/ghcr-images/kustomization.yaml"+ONLY_SVC=""++for arg in "$@"; do+ case "$arg" in+ --only=*) ONLY_SVC="${arg#--only=}" ;;+ esac+done++RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[1;33m'+CYAN='\033[0;36m'+BOLD='\033[1m'+NC='\033[0m'++log() { echo -e "${CYAN}[PULL]${NC} $*"; }+ok() { echo -e "${GREEN} OK${NC} -- $*"; }+warn() { echo -e "${YELLOW} WARN${NC} -- $*"; }+err() { echo -e "${RED} ERROR${NC} -- $*" >&2; }++# ---- Resolve the effective tag -------------------------------------------+# The committed component is the single source of truth. MINIKUBE_IMAGE_TAG is+# an operator lever applied to this run only, never a second writer.+read_pinned_tag() {+ [ -f "$COMPONENT" ] || {+ err "ghcr component not found at ${COMPONENT}"+ exit 1+ }+ local tags+ tags="$(sed -n 's/^[[:space:]]*newTag:[[:space:]]*\([^[:space:]]*\)[[:space:]]*$/\1/p' "$COMPONENT" | sort -u)"+ if [ -z "$tags" ]; then+ err "no newTag: line in ${COMPONENT}; there is no pin to pull"+ exit 1+ fi+ if [ "$(printf '%s\n' "$tags" | wc -l | tr -d ' ')" != "1" ]; then+ err "mixed newTag values in ${COMPONENT}: $(printf '%s ' $tags)"+ exit 1+ fi+ printf '%s' "$tags"+}++if [ -n "${MINIKUBE_IMAGE_TAG:-}" ]; then+ IMAGE_TAG="$MINIKUBE_IMAGE_TAG"+ TAG_ORIGIN="MINIKUBE_IMAGE_TAG override"+else+ IMAGE_TAG="$(read_pinned_tag)"+ TAG_ORIGIN="committed pin in deploy/components/ghcr-images/kustomization.yaml"+fi++# ---- Resolve the pull list ----------------------------------------------+# Emitted as TAB-separated `name<TAB>localRef` by the ONE manifest reader, so+# this script never re-derives published && deployed_to_minikube itself.+PULL_LIST="$(node -e '+ import("'"$PROJECT_DIR"'/scripts/release/images-manifest.mjs").then(m => {+ for (const image of m.pullInGhcrMode()) {+ process.stdout.write(`${image.name}\t${m.localRef(image)}\n`)+ }+ }).catch(err => {+ process.stderr.write(`images-manifest read failed: ${err.message}\n`)+ process.exit(1)+ })')"++if [ -z "$PULL_LIST" ]; then+ err "the manifest produced zero pull_in_ghcr_mode images; refusing to report success on an empty pull"+ exit 1+fi++echo -e "\n${BOLD}=== Pulling Published Images (${IMAGE_TAG}) ===${NC}"+log "tag ${IMAGE_TAG} (${TAG_ORIGIN})"+log "profile ${PROFILE}, parallelism ${PULL_PARALLELISM}"++# ---- Point the Docker CLI at minikube's daemon when safe -----------------+if [ "$MINIKUBE_MULTI_NODE" = false ]; then+ log "Configuring Docker CLI to use minikube's Docker daemon..."+ eval "$(minikube -p "$PROFILE" docker-env)"+ unset DOCKER_API_VERSION 2>/dev/null || true+else+ log "Multi-node profile: pulling on the host, then 'minikube image load' onto every node"+fi++STATUS_DIR="$(mktemp -d)"+cleanup() { rm -rf "$STATUS_DIR"; }+trap cleanup EXIT++# ---- One image ----------------------------------------------------------+pull_one() {+ local name="$1" local_ref="$2" slot="$3"+ local ghcr_ref="${GHCR_NAMESPACE}/${name}:${IMAGE_TAG}"++ # Always pull. Never skip a present tag -- see the header.+ if ! docker pull "$ghcr_ref" >"${STATUS_DIR}/${slot}.out" 2>&1; then+ printf '%s' "$ghcr_ref" > "${STATUS_DIR}/${slot}.failed"+ return 0+ fi++ if [ "$MINIKUBE_MULTI_NODE" = true ]; then+ minikube -p "$PROFILE" image load "$ghcr_ref" >/dev/null 2>&1 || {+ printf '%s' "$ghcr_ref" > "${STATUS_DIR}/${slot}.failed"+ return 0+ }+ fi++ # The local alias. See header note 2.+ if ! docker tag "$ghcr_ref" "$local_ref" >>"${STATUS_DIR}/${slot}.out" 2>&1; then+ printf '%s' "$ghcr_ref (alias to ${local_ref})" > "${STATUS_DIR}/${slot}.failed"+ return 0+ fi+ if [ "$MINIKUBE_MULTI_NODE" = true ]; then+ minikube -p "$PROFILE" image load "$local_ref" >/dev/null 2>&1 || true+ fi++ printf '%s\t%s' "$ghcr_ref" "$local_ref" > "${STATUS_DIR}/${slot}.done"+}++# ---- Parallel fan-out ---------------------------------------------------+slot=0+selected=0+while IFS="$(printf '\t')" read -r name local_ref; do+ [ -n "$name" ] || continue+ if [ -n "$ONLY_SVC" ] && [[ "$name" != *"$ONLY_SVC"* ]] && [[ "$local_ref" != *"$ONLY_SVC"* ]]; then+ continue+ fi+ selected=$((selected + 1))+ slot=$((slot + 1))+ # Bounded concurrency without GNU parallel or `wait -n` (bash 3.2 on macOS).+ while [ "$(jobs -pr | wc -l | tr -d ' ')" -ge "$PULL_PARALLELISM" ]; do+ sleep 0.2+ done+ pull_one "$name" "$local_ref" "$slot" &+done <<< "$PULL_LIST"+wait++if [ "$selected" -eq 0 ]; then+ err "--only=${ONLY_SVC} matched no pull_in_ghcr_mode image"+ exit 1+fi++# ---- Report -------------------------------------------------------------+FAILED=()+for f in "${STATUS_DIR}"/*.failed; do+ [ -e "$f" ] || continue+ FAILED+=("$(cat "$f")")+done++for f in "${STATUS_DIR}"/*.done; do+ [ -e "$f" ] || continue+ ok "$(cut -f1 "$f") -> $(cut -f2 "$f")"+done++if [ "${#FAILED[@]}" -gt 0 ]; then+ echo ""+ err "${#FAILED[@]} of ${selected} image(s) could not be pulled at tag '${IMAGE_TAG}':"+ for ref in "${FAILED[@]}"; do+ err " ${ref}"+ done+ echo "" >&2+ err "The tag '${IMAGE_TAG}' came from the ${TAG_ORIGIN}."+ err "If '${IMAGE_TAG}' has not been promoted yet (the release-prep commit reaches main"+ err "BEFORE the tag is cut and the images are promoted), pull a tag that exists:"+ err " MINIKUBE_IMAGE_TAG=latest make minikube-setup"+ err "Or build everything locally instead:"+ err " make minikube-setup-local"+ exit 1+fi++# ---- Image manifest -----------------------------------------------------+# Same shape build-images.sh writes. scripts/minikube/full-setup.sh:608 uses+# this file as a `find -newer` staleness marker, and its absence makes the ghcr+# path look like "images were never built".+MANIFEST_FILE="${PROJECT_DIR}/deploy/minikube/.image-manifest.json"+mkdir -p "$(dirname "$MANIFEST_FILE")"+{+ echo "{"+ echo " \"generated\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\","+ echo " \"profile\": \"${PROFILE}\","+ echo " \"imageSource\": \"ghcr\","+ echo " \"imageTag\": \"${IMAGE_TAG}\","+ echo " \"images\": {"+ first=true+ for f in "${STATUS_DIR}"/*.done; do+ [ -e "$f" ] || continue+ ghcr_ref="$(cut -f1 "$f")"+ local_ref="$(cut -f2 "$f")"+ sha="$(docker inspect --format='{{.Id}}' "$ghcr_ref" 2>/dev/null || echo "NOT_PULLED")"+ for ref in "$ghcr_ref" "$local_ref"; do+ if [ "$first" = true ]; then first=false; else echo ","; fi+ printf ' "%s": "%s"' "$ref" "$sha"+ done+ done+ echo ""+ echo " }"+ echo "}"+} > "$MANIFEST_FILE"+ok "Manifest: deploy/minikube/.image-manifest.json"++echo ""+echo -e "${GREEN}${BOLD}All ${selected} published image(s) pulled at ${IMAGE_TAG} into minikube '${PROFILE}'.${NC}"diff --git a/scripts/tests/test-minikube-pull-images.sh b/scripts/tests/test-minikube-pull-images.shnew file mode 100755index 000000000..088633e45--- /dev/null+++ b/scripts/tests/test-minikube-pull-images.sh@@ -0,0 +1,245 @@+#!/usr/bin/env bash+set -u+FAIL=0++# scripts/minikube/pull-images.sh replaces the 20-minute local build on the+# default setup path. Every case runs it against PATH stubs for docker/minikube+# (the same technique as scripts/tests/test-minikube-full-setup.sh) so nothing+# here needs a cluster or a network.++REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+SCRIPT="$REPO_ROOT/scripts/minikube/pull-images.sh"++pass() { echo "PASS: $1"; }+fail() { echo "FAIL: $1"; FAIL=1; }++# Builds a stub bin dir. `docker` logs every invocation and fails any pull whose+# ref appears in $TEST_MISSING_TAGS, which is how the missing-tag cases work.+make_stubs() {+ local d=$1+ mkdir -p "$d/bin"+ cat > "$d/bin/docker" <<'STUB'+#!/usr/bin/env bash+printf '%s\n' "$*" >>"${TEST_LOG_FILE:?}"+case "${1:-}" in+ pull)+ for missing in ${TEST_MISSING_TAGS:-}; do+ if [[ "${2:-}" == "$missing" ]]; then+ echo "Error response from daemon: manifest unknown" >&2+ exit 1+ fi+ done+ exit 0+ ;;+ tag) exit 0 ;;+ images) echo "sha256:aaaaaaaaaaaa"; exit 0 ;;+ inspect) echo "sha256:aaaaaaaaaaaabbbbbbbbbbbbcccccccccccc"; exit 0 ;;+ *) exit 0 ;;+esac+STUB+ cat > "$d/bin/minikube" <<'STUB'+#!/usr/bin/env bash+printf 'minikube %s\n' "$*" >>"${TEST_LOG_FILE:?}"+if [[ "$*" == *"docker-env"* ]]; then+ echo 'export DOCKER_HOST="tcp://127.0.0.1:2376"'+ exit 0+fi+exit 0+STUB+ chmod +x "$d/bin/docker" "$d/bin/minikube"+}++# Runs the script in an isolated PROJECT_DIR that is a copy of the real repo's+# deploy/ + scripts/, so it reads the REAL deploy/images.json and the REAL+# component pin rather than a fixture that could drift from them.+run_puller() {+ local d=$1; shift+ make_stubs "$d"+ mkdir -p "$d/repo"+ cp -R "$REPO_ROOT/deploy" "$d/repo/deploy"+ cp -R "$REPO_ROOT/scripts" "$d/repo/scripts"+ PATH="$d/bin:$PATH" \+ TEST_LOG_FILE="$d/ops.log" \+ TEST_MISSING_TAGS="${TEST_MISSING_TAGS:-}" \+ bash "$d/repo/scripts/minikube/pull-images.sh" "$@" 2>&1+}++assert_it_pulls_every_pull_in_ghcr_mode_image() {+ local d out rc want got+ d="$(mktemp -d)"+ out="$(run_puller "$d")"; rc=$?+ want="$(node -e '+ import("'"$REPO_ROOT"'/scripts/release/images-manifest.mjs")+ .then(m => console.log(m.pullInGhcrMode().length))' 2>&1)"+ got="$(grep -c '^pull ghcr\.io/evenfire-ai/' "$d/ops.log" || true)"+ if [ "$rc" -eq 0 ] && [ "$got" = "$want" ]; then+ pass "pulled all $want pull_in_ghcr_mode images"+ else+ fail "expected $want pulls, got '$got' (rc=$rc): $out"+ fi+ rm -rf "$d"+}++# The derivation guard at the consumer end. The three published:false images+# have no ghcr counterpart at all; pulling one fails with MANIFEST_UNKNOWN and+# takes the whole default setup down with it.+assert_it_never_pulls_an_unpublished_image() {+ local d out bad+ d="$(mktemp -d)"+ out="$(run_puller "$d")"+ bad="$(grep -E '^pull ghcr\.io/evenfire-ai/(workflow-custom-sdk-e2e|workflow-plugin-sdk-e2e|doc-generator-mcp):' "$d/ops.log" || true)"+ if [ -z "$bad" ]; then+ pass "no unpublished image was pulled"+ else+ fail "pulled unpublished image(s): $bad"+ fi+ rm -rf "$d"+}++# The behaviour a "smart" puller would delete. A pre-gate shadow build is+# tagged with the exact ghcr ref, so skipping present tags would keep it alive+# across setups and make gates test undeployed code.+assert_it_repulls_a_tag_already_present_in_the_daemon() {+ local d out pulls+ d="$(mktemp -d)"+ # The docker stub answers `images -q` with a digest for every ref, i.e. every+ # tag reports as already present.+ out="$(run_puller "$d" --only=control-api)"+ pulls="$(grep -c '^pull ghcr\.io/evenfire-ai/control-api:' "$d/ops.log" || true)"+ if [ "$pulls" -ge 1 ]; then+ pass "re-pulls a tag the daemon already reports as present"+ else+ fail "skipped a present tag; a shadow build would survive invisibly: $out"+ fi+ rm -rf "$d"+}++# Six pull_in_ghcr_mode images have no overlay row and are consumed under their+# local clerum/ names by McpServer CRD instances and E2E scripts.+assert_it_aliases_each_image_to_its_local_ref() {+ local d out missing+ d="$(mktemp -d)"+ out="$(run_puller "$d")"+ missing=""+ for ref in clerum/airtable-mcp-server:test clerum/web-search-mcp:v1 \+ clerum/mock-mcp-server:test clerum/mock-stdio-mcp-server:test \+ clerum/mcp-host-slim:test clerum/mcp-host-full:test \+ clerum/control-api:test; do+ grep -q "^tag ghcr\.io/evenfire-ai/[a-z0-9.:-]* ${ref}\$" "$d/ops.log" || missing+=" $ref"+ done+ if [ -z "$missing" ]; then+ pass "every pulled image is aliased to its local clerum/ ref"+ else+ fail "missing local aliases:$missing"+ fi+ rm -rf "$d"+}++# web-search-mcp uses local_tag v1, not test. Hardcoding :test here would break+# every McpServer instance that names it.+assert_the_alias_honours_local_tag_and_local_name() {+ local d out+ d="$(mktemp -d)"+ out="$(run_puller "$d" --only=web-search-mcp)"+ if grep -q '^tag ghcr\.io/evenfire-ai/web-search-mcp:[^ ]* clerum/web-search-mcp:v1$' "$d/ops.log"; then+ pass "the alias uses localRef(), honouring local_tag"+ else+ fail "web-search-mcp was not aliased to clerum/web-search-mcp:v1: $out"+ fi+ rm -rf "$d"+}++# The promotion-to-tag window is inherent to pinning in the tree (a fresh clone+# of main can pin a tag that is not promoted yet). A raw MANIFEST_UNKNOWN gives+# a new contributor nothing to act on.+assert_a_missing_tag_names_the_tag_and_the_override() {+ local d out rc+ d="$(mktemp -d)"+ # `A=1 out="$(cmd)"` does NOT put A in cmd's environment: every assignment's+ # value is expanded BEFORE any of them takes effect. Export it instead.+ export TEST_MISSING_TAGS="ghcr.io/evenfire-ai/control-api:v0.6.0"+ out="$(run_puller "$d" --only=control-api)"; rc=$?+ unset TEST_MISSING_TAGS+ if [ "$rc" -ne 0 ] \+ && grep -q "v0.6.0" <<< "$out" \+ && grep -q "MINIKUBE_IMAGE_TAG" <<< "$out" \+ && grep -q "control-api" <<< "$out"; then+ pass "a missing tag fails naming the image, the tag, and MINIKUBE_IMAGE_TAG"+ else+ fail "expected a named failure mentioning control-api, v0.6.0 and MINIKUBE_IMAGE_TAG; got rc=$rc out='$out'"+ fi+ rm -rf "$d"+}++assert_minikube_image_tag_overrides_the_pin() {+ local d out+ d="$(mktemp -d)"+ out="$(MINIKUBE_IMAGE_TAG=latest run_puller "$d" --only=control-api)"+ if grep -q '^pull ghcr\.io/evenfire-ai/control-api:latest$' "$d/ops.log"; then+ pass "MINIKUBE_IMAGE_TAG overrides the committed pin"+ else+ fail "MINIKUBE_IMAGE_TAG=latest did not reach the pull: $out"+ fi+ rm -rf "$d"+}++# full-setup.sh:608 uses this file as a `find -newer` marker and warns loudly+# when it is absent. Writing it is what keeps the ghcr path from looking like+# "images were never built".+assert_it_writes_the_image_manifest_consumers_read() {+ local d out+ d="$(mktemp -d)"+ out="$(run_puller "$d")"+ local f="$d/repo/deploy/minikube/.image-manifest.json"+ if [ ! -f "$f" ]; then+ fail "no .image-manifest.json written: $out"; rm -rf "$d"; return 0+ fi+ local bad+ bad="$(node -e '+ const fs = require("node:fs")+ let j+ try { j = JSON.parse(fs.readFileSync("'"$f"'", "utf8")) }+ catch (e) { console.log(`PARSE_ERROR: ${e.message}`); process.exit(1) }+ const problems = []+ if (typeof j.generated !== "string" || !j.generated) problems.push("generated")+ if (typeof j.profile !== "string" || !j.profile) problems.push("profile")+ if (!j.images || typeof j.images !== "object") problems.push("images")+ else {+ const keys = Object.keys(j.images)+ if (!keys.some(k => k.startsWith("ghcr.io/evenfire-ai/"))) problems.push("no ghcr keys")+ if (!keys.some(k => k.startsWith("clerum/"))) problems.push("no local alias keys")+ }+ console.log(problems.join(","))+ ' 2>&1)"+ if [ -z "$bad" ]; then+ pass "the image manifest has the shape full-setup.sh consumes, with both key forms"+ else+ fail "image manifest shape problems: $bad"+ fi+ rm -rf "$d"+}++assert_every_defined_case_is_invoked() {+ local self defined invoked missing+ self="$REPO_ROOT/scripts/tests/test-minikube-pull-images.sh"+ defined="$(grep -oE '^assert_[a-z_]+\(\) \{' "$self" | sed -E 's/\(\) \{$//' | sort -u)"+ invoked="$(grep -oE '^assert_[a-z_]+$' "$self" | sort -u)"+ missing="$(comm -23 <(printf '%s\n' "$defined") <(printf '%s\n' "$invoked"))"+ if [ -z "$missing" ]; then+ pass "every defined assert_ case is invoked in the call block"+ else+ fail "defined but never invoked: $(printf '%s ' $missing)"+ fi+}++assert_it_pulls_every_pull_in_ghcr_mode_image+assert_it_never_pulls_an_unpublished_image+assert_it_repulls_a_tag_already_present_in_the_daemon+assert_it_aliases_each_image_to_its_local_ref+assert_the_alias_honours_local_tag_and_local_name+assert_a_missing_tag_names_the_tag_and_the_override+assert_minikube_image_tag_overrides_the_pin+assert_it_writes_the_image_manifest_consumers_read+assert_every_defined_case_is_invoked++exit $FAIL