Repository navigation
feat(custom-app): disk admission at the digest pull (Feature 4 — HLD §9) - #148
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5da67aee7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| free = _disk_free_bytes(settings) | ||
| if free is not None and ( | ||
| size + settings.greffer_image_min_free_bytes > free): |
There was a problem hiding this comment.
Avoid counting image bytes twice in the free-space check
_admit_image runs after images.pull, so the reported free space already excludes the pulled image's storage. Adding its full size again incorrectly refuses images even when the configured keep-free margin is satisfied, including fully cached images that require no additional disk space. For example, a cached 4 GiB image on a node with 3 GiB free is refused with the default 2 GiB margin. Compare post-pull free space against the margin alone; any pre-pull capacity check should separately account for additional bytes required.
Useful? React with 👍 / 👎.
| if settings is not None and settings.greffer_image_count_max: | ||
| try: | ||
| count = len(compose_mod.client.images.list()) |
There was a problem hiding this comment.
Enforce the image-count cap throughout the service loop
When GREFFER_IMAGE_COUNT_MAX is enabled, the image count is checked only once before processing all services. A node holding one image with a cap of two therefore accepts a compose containing multiple distinct new images, pulls all of them, and exceeds the configured cap. Recheck or track the count as new images are introduced so later services cannot bypass admission within the same request.
Useful? React with 👍 / 👎.
5da67ae to
44dea76
Compare
A precondition, a cap, and a cleanup, enforced at the preflight's
digest pull — the one pull the platform controls. Free space reads
statvfs on greffon_path (the heartbeat's existing disk-free signal;
docker df() is the most expensive call in the design and has no place
in a request path). Size and count judge attrs['Size'] after the pull
(exact, not estimated). A refused image this pull INTRODUCED is
removed BY IMAGE ID; pre-existence is probed by identity (a moved
mutable tag introduces a new image under the same name) and doubt
reads as "not ours to delete". All refusals are the preflight's 422
rows naming image, size, cap and the env knob.
Knobs are operator-owned with typo-must-not-crash coercion that also
accepts the platform's size syntax ("50g", like the limits knobs):
MAX 20 GiB and MIN_FREE 2 GiB default ON (protective without
refusing legitimate apps); COUNT defaults OFF — node images are
mostly the catalog tier's pulls, and charging those to a custom
create refuses tenants for usage they did not cause. Free-space read
failures fail open, logged.
Review folds:
- codex P1: the headroom precondition runs BEFORE each pull — with
the disk already at/below the margin the refusal happens without
pulling (a multi-GiB pull on an exhausted disk would run to ENOSPC,
bypassing admission AND cleanup); the exact size-vs-margin judgment
still runs post-pull.
- codex P2: count-cap slot accounting — the snapshot cannot see this
request's own additions, so each image the loop introduces consumes
a slot and the second new image is refused before it is pulled.
- codex P2: cleanup keyed on image IDENTITY — tag presence lies when
a mutable tag is cached at digest A but the registry serves B; the
refusal removes B by ID, never A.
- adversarial P2s: the count reads the low-level one-call API
(images.list() inspects every image — an N+1 storm on the shared
threadpool token); the knobs accept parse_size units (a "50g" that
silently landed on the 20 GiB default was a trap 2.5x off intent).
- Grain notes documented: cleanup is per-image (a multi-service
refusal keeps earlier images as warm layer cache); Size is virtual,
so a fully-cached image can still trip the margin on purpose.
Suites: preflight 28 OK incl. 9 admission; settings 19 OK; full 1125
passed with only the pre-existing oracle/catalog-pin artifact.
44dea76 to
bc92baa
Compare
Custom-app-deploy foundation Feature 4, disk-admission slice (HLD §9: "a precondition, a cap, and a cleanup").
What
Enforcement lives at the preflight's digest pull — the one pull the platform controls (catalog pulls ride docker-compose up without us; the start path re-pulls the same digest with layers cached).
statvfsongreffon_path(the heartbeat's existing disk-free signal — a real filesystem call;docker df()walks every volume on the host and is the most expensive call in the design). Refuse whenimage_size + keep_free > free. On the standard single-disk install the data volume and the engine share a disk; split-disk hosts should rely on the size cap (documented).attrs['Size']— exact, not estimated).key: "image", message naming image, size, cap, and the env knob) — the manager relays them at create time.Knobs (operator-owned,
app/settings.py, typo-must-not-crash coercion like the limits feature):GREFFER_IMAGE_MAX_BYTESGREFFER_IMAGE_MIN_FREE_BYTESGREFFER_IMAGE_COUNT_MAXThe count cap defaults OFF deliberately: images already on the node are mostly the catalog tier's pulls, and charging those to a custom create would refuse tenants for usage they did not cause. Free-space read failures fail open (logged) — a transient statvfs error must not become a wrong create refusal.
run_preflight(..., settings=None)keeps the unit-callable default (no admission) — the router passes the app settings; the route test proves the wiring.Tests
Six admission unit tests (size refusal + cleanup, pre-existing never removed, free-space refusal, read-failure fail-open, count refusal before any pull, settings-absent = old behavior), two settings tests (protective defaults, junk→default), one route test (knobs reach the pull, 422 shape). Conftest neutralizes the knobs for the shared app so route tests stay machine-independent.
Boundary
Failed pulls (as opposed to refused ones) leave no image object to remove; orphan layer blobs are the daemon's own GC territory — pruning dangling images globally would touch other tenants' state. Named in the PR rather than left implied.