Repository navigation
Feature/admin bake endpoint - #286
Merged
Merged
Conversation
bake turns a deployed build box into a Quick Deploy snapshot. It was not in the image, so every bake meant compiling it by hand and `docker cp` into the running container. CI now compiles it with the other release binaries, archives and unpacks it, and both Dockerfile paths (prebuilt from CI and the local builder stage) copy it to /app/bake. tests/image_binaries_contract.rs checks every image binary on both paths (failed for bake before this change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012TKZy6f5shPzM9WLdswH6f
POST /api/admin/bake {deployment_id, stack, health_url} bakes a deployed
build box into a Quick Deploy snapshot; GET /api/admin/bake/{id} reports
the job. Admins only (group_admin, admin_service), like template approval.
What the bake binary needs typed by hand comes from stacker itself: the
server row of the deployment's project (IP, SSH user and port), its SSH
key in Vault, and the latest approved version of the template with its
config_contract. Refused at once, with no job recorded and the box
untouched: unknown deployment, not exactly one server, a template that is
not approved, no or unusable contract, a health URL that is not on the
box, a box Hetzner does not know in the platform's project, a bake of the
same box already running.
The job (202 + id, status in the new bake_job table) then checks the
health URL, finds the stack's directory with `docker compose ls` and
requires every service up (`docker compose ps`), and runs the existing
chain unchanged: finalize_build_box, run_bake, baked_snapshot::record.
The build box is never removed.
Tests: helpers::bake_job (7, written failing first); tests/admin_bake.rs
(refusals, accepted job, status, non-admin refused; a mutation that drops
the Hetzner lookup fails it). lib + route matrix 2270 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012TKZy6f5shPzM9WLdswH6f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for a new "bake job" feature, which allows the system to initiate and track "bake" operations through the API and a new
bakebinary. The changes include database schema migrations, backend logic, and updates to Docker and build workflows to incorporate the new binary. Additionally, helper utilities and models are added to support the new functionality.Bake Job Feature Implementation:
Database schema and migrations:
bake_jobtable for tracking bake jobs, including fields for stack, version, deployment, server info, status, and error reporting. Associated Casbin rules are inserted for API access, and a down migration is provided for cleanup. [1] [2]Backend logic and models:
BakeJobstruct insrc/models/bake_job.rsand exposes it in the models module. [1] [2] [3]src/db/bake_job.rs, including creation, fetching, status updates, and concurrency checks. [1] [2]Helper utilities:
src/helpers/bake_job.rswith functions to validate stack directories, check the status of compose services, and verify health URLs, including comprehensive tests.src/helpers/mod.rs.PLATFORM_INSTALL_DIRSpublic for use in helpers.Docker and Build Workflow Updates:
bakebinary in the application image and deployment artifacts. [1] [2] [3] [4] [5] [6]