Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
perf(preview): pull receipt so warm boots skip mirrored images (#4964)
teo39380ecbcd93
diff --git a/.github/workflows/preview-fly.yml b/.github/workflows/preview-fly.ymlindex 1834988aa6..e84629f17e 100644--- a/.github/workflows/preview-fly.yml+++ b/.github/workflows/preview-fly.yml@@ -293,8 +293,12 @@ jobs:# A suspended preview needs demand before SSH is reachable.curl -s -o /dev/null --max-time 10 "https://$APP_NAME.fly.dev/" || truefor _ in $(seq 1 12); do+ # `--command` is exec'd directly, NOT run through a shell —+ # a bare `if [ -f ...` dies with `exec: "if": not found`, so+ # the marker never parsed and every push silently rehydrated+ # (~7 min) instead of going hot (~3 min). Hence the sh -c.marker=$(flyctl ssh console --app "$APP_NAME" --machine "$machine_id" \- --quiet --command 'if [ -f /var/lib/docker/.macro-preview/deployment.json ]; then cat /var/lib/docker/.macro-preview/deployment.json; else echo __NO_MARKER__; fi' \+ --quiet --command 'sh -c "if [ -f /var/lib/docker/.macro-preview/deployment.json ]; then cat /var/lib/docker/.macro-preview/deployment.json; else echo __NO_MARKER__; fi"' \2>/dev/null || true)if echo "$marker" | jq -e \--arg key "$snapshot_key" \diff --git a/infra/preview/entrypoint.sh b/infra/preview/entrypoint.shindex f722508ff4..37893aad2d 100644--- a/infra/preview/entrypoint.sh+++ b/infra/preview/entrypoint.sh@@ -47,6 +47,16 @@ if [ -f /srv/macro/preload/manifest.txt ]; thenfilog "pulling stack images (parallel, warm store aware)"t0=$(date +%s)+ # The manifest's IDs are the RUNNER's view of each image (for hub images+ # under the containerd store, the source registry's index digest). Pulling+ # the mirror yields a different manifest and therefore a different local+ # .Id, so the inspect check below never matches mirrored images and every+ # boot re-pulled all 16 (66s of pure round-trips on a fully warm volume).+ # The receipt is our own volume-persisted record of which (runner id, tag)+ # pairs this store already satisfied — written only after a fully+ # successful pass, carried along by template-volume forks, and at worst+ # stale in the direction of one redundant pull.+ receipt="$state_dir/pulled.txt"pids=""while read -r id tag ref; dohave=$(docker image inspect -f '{{.Id}}' "$tag" 2>/dev/null || true)@@ -54,12 +64,18 @@ if [ -f /srv/macro/preload/manifest.txt ]; thenlog "already present: $tag"continuefi+ if [ -n "$have" ] && grep -qxF "$id $tag" "$receipt" 2>/dev/null; then+ log "already present (receipt): $tag"+ continue+ fi(docker pull -q "$ref" && docker tag "$ref" "$tag" && docker rmi "$ref" >/dev/null) &pids="$pids $!"done < /srv/macro/preload/manifest.txtrc=0for pid in $pids; do wait "$pid" || rc=1; done[ "$rc" = 0 ] || { log "image pull failed"; exit 1; }+ awk '{print $1, $2}' /srv/macro/preload/manifest.txt > "$receipt.next" \+ && mv "$receipt.next" "$receipt"log "images pulled in $(($(date +%s) - t0))s"fidiff --git a/infra/preview/hot-update.sh b/infra/preview/hot-update.shindex c31a1c79b6..6239a6453b 100644--- a/infra/preview/hot-update.sh+++ b/infra/preview/hot-update.sh@@ -66,6 +66,15 @@ unsafe_images=while read -r expected_id tag registry_ref; docurrent_id=$(docker image inspect -f '{{.Id}}' "$tag" 2>/dev/null || true)[ "$current_id" = "$expected_id" ] && continue+ # Mirrored images never match by .Id (the manifest carries the runner's+ # source-registry digest; this store holds the mirror's) — same mismatch+ # the entrypoint's pull loop handles. Honor the boot pull receipt before+ # classifying an image as changed, or every hot update sees all 12 infra+ # images as "non-hot-updatable drift" and needlessly rehydrates.+ if [ -n "$current_id" ] \+ && grep -qxF "$expected_id $tag" "$STATE_DIR/pulled.txt" 2>/dev/null; then+ continue+ ficase "$tag" in*-ai_editing_worker|*-lexical_service|*-sync_service|*-websocket_service)log "refreshing auxiliary image $tag"@@ -108,6 +117,11 @@ install -m 0755 "$staging/xtask" /srv/macro/bin/xtask.nextmv -f /srv/macro/bin/xtask.next /srv/macro/bin/xtaskinstall -m 0644 "$staging/deployment.json" "$STATE_FILE.next"mv -f "$STATE_FILE.next" "$STATE_FILE"+# The aux refreshes above satisfied the carrier manifest, so record it in the+# boot pull receipt — otherwise the next real boot re-pulls what this update+# already delivered (see the receipt logic in entrypoint.sh).+awk '{print $1, $2}' "$staging/manifest.txt" > "$STATE_DIR/pulled.txt.next" \+ && mv "$STATE_DIR/pulled.txt.next" "$STATE_DIR/pulled.txt"# Retain the current carrier's layers for the next incremental pull, but remove# older carrier tags and their now-unreferenced layers from the persistent store.diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/preview_fly.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/preview_fly.rsindex e8a057002e..53415d7f2c 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/preview_fly.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/preview_fly.rs@@ -467,8 +467,12 @@ fn deploy_to_fly() -> Step<Run> {# A suspended preview needs demand before SSH is reachable.curl -s -o /dev/null --max-time 10 "https://$APP_NAME.fly.dev/" || truefor _ in $(seq 1 12); do+ # `--command` is exec'd directly, NOT run through a shell —+ # a bare `if [ -f ...` dies with `exec: "if": not found`, so+ # the marker never parsed and every push silently rehydrated+ # (~7 min) instead of going hot (~3 min). Hence the sh -c.marker=$(flyctl ssh console --app "$APP_NAME" --machine "$machine_id" \- --quiet --command 'if [ -f /var/lib/docker/.macro-preview/deployment.json ]; then cat /var/lib/docker/.macro-preview/deployment.json; else echo __NO_MARKER__; fi' \+ --quiet --command 'sh -c "if [ -f /var/lib/docker/.macro-preview/deployment.json ]; then cat /var/lib/docker/.macro-preview/deployment.json; else echo __NO_MARKER__; fi"' \2>/dev/null || true)if echo "$marker" | jq -e \--arg key "$snapshot_key" \