runpod: bake the image tag into the pod, and record the whole startup in /boot

A pod could not say WHICH build it was running, which is exactly the question a
cached ':latest' raises — an images pod reported a dependency missing that had
already been published under that tag. The build now bakes IMAGE_TAG in, so the
boot record names the image.

/boot also showed only 'lifespan start': the seed registration and the end of
startup were plain prints. They are phases now, so one request covers the whole
boot including how many seeded models registered and whether that step failed.
Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0182DhR1eFNPQyGmDrpHbedY
parent 3fdabcc3
...@@ -140,12 +140,16 @@ async def lifespan(app: FastAPI): ...@@ -140,12 +140,16 @@ async def lifespan(app: FastAPI):
flush=True) flush=True)
_seeds = [e for e in (getattr(_cm, "_pending_seed_entries", None) or []) _seeds = [e for e in (getattr(_cm, "_pending_seed_entries", None) or [])
if isinstance(e, dict) and e.get("path")] if isinstance(e, dict) and e.get("path")]
print(f"[seed] {len(_seeds)} seeded model(s) to register", flush=True) boot_phase(f"registering {len(_seeds)} seeded model(s)")
for _entry in _seeds: for _entry in _seeds:
register_model_runtime(_entry, register_model_runtime(_entry,
_entry.get("model_type") or "text_models") _entry.get("model_type") or "text_models")
if _seeds:
boot_phase("seeded models registered: "
+ ", ".join(str(e.get("alias") or e.get("path"))
for e in _seeds)[:200])
except Exception as _exc: except Exception as _exc:
print(f"[seed] could not register seeded models: {_exc}", flush=True) boot_phase(f"SEED REGISTRATION FAILED: {_exc}")
# Start any RunPod pod configured to stay warm. Pools are otherwise created # Start any RunPod pod configured to stay warm. Pools are otherwise created
# on first use, so the first request after a restart would still pay the cold # on first use, so the first request after a restart would still pay the cold
...@@ -159,6 +163,8 @@ async def lifespan(app: FastAPI): ...@@ -159,6 +163,8 @@ async def lifespan(app: FastAPI):
except Exception: except Exception:
pass pass
boot_phase("startup complete — accepting requests")
yield yield
if broker_service is not None: if broker_service is not None:
......
...@@ -23,6 +23,12 @@ FROM ${CORE_BASE} ...@@ -23,6 +23,12 @@ FROM ${CORE_BASE}
ARG PROFILE=images ARG PROFILE=images
ARG TORCH_INDEX=https://download.pytorch.org/whl/cu124 ARG TORCH_INDEX=https://download.pytorch.org/whl/cu124
ENV PROFILE=${PROFILE} ENV PROFILE=${PROFILE}
# Baked at build time so the pod can say WHICH build it is. A machine may serve
# a cached `:latest`, and an images pod once reported a dependency missing that
# had already been published under that tag — with no way to tell from outside
# whether the pod ran the new image or an old one. Now it says so at boot.
ARG IMAGE_TAG=unknown
ENV CODERAI_IMAGE_TAG=${IMAGE_TAG}
WORKDIR /opt/coderai/app WORKDIR /opt/coderai/app
COPY packaging/runpod/profiles/ /tmp/profiles/ COPY packaging/runpod/profiles/ /tmp/profiles/
......
...@@ -57,6 +57,7 @@ echo "==> building $TAG from profile '$PROFILE'" ...@@ -57,6 +57,7 @@ echo "==> building $TAG from profile '$PROFILE'"
# BuildKit for the pip cache mount: nine profiles, one torch download. # BuildKit for the pip cache mount: nine profiles, one torch download.
DOCKER_BUILDKIT=1 docker build -f packaging/runpod/Dockerfile.capability \ DOCKER_BUILDKIT=1 docker build -f packaging/runpod/Dockerfile.capability \
--build-arg "PROFILE=$PROFILE" \ --build-arg "PROFILE=$PROFILE" \
--build-arg "IMAGE_TAG=$TAG" \
--build-arg "CORE_BASE=$CORE_BASE" \ --build-arg "CORE_BASE=$CORE_BASE" \
-t "$TAG" . -t "$TAG" .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment