Skip to content

Features: engine metrics, a prune that keeps N, container checkpoints, and sealed secrets - #920

Open
sturdymushroom wants to merge 1 commit into
libracoder:mainfrom
sturdymushroom:features-wave
Open

sturdymushroom wants to merge 1 commit into
libracoder:mainfrom
sturdymushroom:features-wave

Conversation

@sturdymushroom

@sturdymushroom sturdymushroom commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Four features toward making Kiri the better Docker.

GET /metrics — Prometheus 0.0.4 text, hand-rolled (no new dependencies), read only from the engine's own state so a scrape never stalls on the guest: kiri_containers{state="..."} (Docker's words, paused included), kiri_containers_total, kiri_images, kiri_image_bytes, kiri_volumes, kiri_networks.

POST /images/prune?keep=N — the sweep stays exactly what it is today, caller-initiated (a sweeper Kiri runs on its own still isn't a thing, #895). This adds two-phase select-then-delete: the N newest unused images across the whole list are kept before anything goes. Unparsable keep is a 400; an image whose created never parsed sorts last (first dropped beyond the kept few).

POST /kiri/containers/<id>/checkpoint — the container's writable files become an image, named by the body's reference (repo or repo:tag) or by a default checkpoint:<shortid>-<unix time> whose seconds change with every call: the checkpoints of a container stack up, none overwrites an earlier one. Restoring one is running it — a checkpoint is files, not the process table. On a stopped engine the checkpoint of a created container says so plainly ("Kiri is stopped") instead of pretending.

Kiri secrets — values sealed at rest with ChaCha20-Poly1305 under the engine's own key (secrets.key, 0600, from the system RNG; ring was already in the tree for rustls), in secrets.json beside the engine's other state, saved atomically like the rest. Listed and read by name only — no endpoint returns a value. A container's start names one in its env with secret:<name> (alone, or as any entry's value) and only there does the plaintext reach the guest; the record keeps the reference, so a copied containers.json carries names, not secrets. An unknown name errors at the start (no secret named ...), as Docker's create answers no such secret.

Testing

  • cargo test -p kiri: 986 passed, 0 failed (+ linux_unit 1/0). New tests: prune's keep (newest kept, 400 on soon/1.5), the checkpoint name rules (incl. localhost:5000/repo — its colon is not a tag's), checkpoint of an unknown container and of one the stopped engine cannot reach, secrets round-trip and persistence (a second engine reads what the first sealed), the API listing without any value, and the /metrics snapshot against computed engine counts.
  • cargo clippy -p kiri: clean on the touched regions.
  • Workspace: cargo test --workspace --exclude kiri-init --locked green — 1260 passed, 0 failed across the 16 crates.
  • Signed with the usual SSH key.

The metrics/prune/secrets paths stay off the request hot path (a /metrics arm, a prune the client asked for, and an env scan only when an entry actually names a secret), so nothing in Speed's measured calls changes.

…ecrets

- GET /metrics: Prometheus 0.0.4 text over engine-held state, no guest
  round-trips: containers by state, total, images, image bytes, volumes,
  networks.
- POST /images/prune?keep=N: two-phase select then delete, keeping the N
  newest unused images across the whole list before anything goes; the
  sweep stays caller-initiated (a sweeper Kiri runs on its own still
  isn't a thing, libracoder#895). Unparsable keep is a 400; an image whose created
  never parsed sorts last.
- POST /kiri/containers/<id>/checkpoint: the container's writable files
  as an image, named by the body's reference or by a default
  checkpoint:<shortid>-<unix time> that stacks. Restoring is running the
  image: a checkpoint is files, not the process table.
- Kiri secrets: values sealed with ChaCha20-Poly1305 under a 0600 key
  beside the engine's state, listed and read by name, never handed back;
  a container start names one in its env with secret:<name> and only
  there does the value reach the guest, the record keeping the
  reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant