Repository navigation
install: Add an experimental library API for installers (PoC) - #37
cgwalters-bot wants to merge 2 commits into
Conversation
Installers that build on bootc today fork/exec `bootc install to-filesystem` and get back only human-oriented stdout: there is no progress to show in a GUI, and finding the new deployment's /etc and /var to inject configuration before the first boot means poking at the ostree layout (bootc-dev#536). The install code already lives in bootc-lib, so expose that path as a small Rust API instead: the caller partitions and mounts the target as with to-filesystem, then gets step progress via a callback, an outcome with the deployment's paths, and errors that carry a kind rather than an exit status. A library must not re-exec its caller, so in this mode the SELinux setup reports a typed environment error when the process can't write arbitrary labels, instead of re-executing itself into install_t. The source image is always given explicitly, as with --source-imgref, which already skips the mount namespace re-exec. This is a proof of concept for discussion in bootc-dev#542; the module is documented as unstable. bootc's status lines still go to stdout. Generated-by: AI
A minimal consumer of the installer API, playing the part of an installer: it partitions and formats a disk image through a loop device, installs to it while printing progress, and writes the outcome as JSON. It is also a handy way to check by hand that the API produces a bootable disk. Generated-by: AI
0daf35c to
04fd1b3
Compare
cgwalters-bot
left a comment
There was a problem hiding this comment.
Review guide for head 04fd1b33b1: where to look closely and what is safe to skim. It is advice from the bot's reviewer and doesn't replace reading the diff; the review app walks it.
Exposes bootc install to-filesystem as an unstable Rust API (bootc_lib::install_api): a builder that maps onto InstallToFilesystemOpts, a step progress callback, an InstallOutcome with the deployment's etc/var paths, and errors with a kind. The CLI path gains an Invocation parameter; in library mode bootc refuses to re-exec for SELinux and skips the completion message. Risk is mostly in the SELinux library branch, the outcome paths (especially composefs, untested end to end), and side effects the library still has on the caller's process: mounts on /tmp and efivarfs, and stdout status lines. A unit test now checks that the builder produces exactly what clap parses for the equivalent CLI flags.
Hotspots
- look-closely · logic —
crates/lib/src/install.rs:1498-1511(a10465e): Library mode never re-execs into install_t and has no setenforce fallback; it relies on test_install_t succeeding (install_t or permissive host). Check this is the behaviour wanted for installers like Anaconda. - look-closely · logic —
crates/lib/src/install.rs:2274-2280(a10465e): Composefs outcome hardcodes the default stateroot and shared var path; it was not tested end to end, so verify these match where composefs deployments really put etc and var. - note · error-handling —
crates/lib/src/install/api.rs:430-452(a10465e): Only empty source, non-root/CAP_SYS_ADMIN and host-root targets get InvalidOptions/Environment up front; other bad options (bad transport, composefs conflicts) still surface as Install. - note · test-gap —
crates/lib/src/install/api.rs:457-510(a10465e): Parity test against clap; it already caught the target transport being docker:// instead of registry. New builder options should be added to its cases.
Safe to skim
crates/lib/src/cli.rs: Mechanical: pass Invocation::Cli and drop the outcome.crates/lib/src/lsm.rs: Visibility change only.crates/lib/src/lib.rs: Module re-export and doc index.
|
Independent review: minor fixes, now amended into the two commits (head 04fd1b3). The shape holds up. The builder maps onto the CLI's to-filesystem path, the SELinux library branch errors instead of re-executing, the outcome paths match the ostree layout, and the module docs mark it unstable. What I checked: the builder against the CLI defaults (SELinux, stateroot, kargs, bound images, composefs, target transport), the error classification, re-exec and stdout/exit in the library path, the progress step order for both backends, the docs, the example, the tests, and AGENTS.md/REVIEW_RUST.md. I also checked the reply on bootc-dev#542 against the code. It is accurate, so I didn't post a correction there. What I changed:
Not changed, but worth knowing:
Tested on a 16-core RHEL 10 devspace. Clippy for bootc-lib passed with Generated-by: https://github.com/cgwalters/#llms |
|
Superseded by #38, which adds the Generated-by: https://github.com/cgwalters/#llms |
Proof of concept for bootc-dev#542, as a draft to discuss the shape:
bootc install to-filesystemexposed as a Rust API for installers. The caller partitions and mounts the target, then gets progress through a callback, an outcome with the deployment's paths, and typed errors.What's in:
bootc_lib::install_api, documented as unstable. It has anInstallerbuilder,FilesystemTarget, progressEvents for the steps (Prepare, Deploy, Bootloader, BoundImages, Finalize), andInstallOutcome. The outcome holds the backend, stateroot, deployment,/etcand/varpaths, and bootloader. It isSerialize, so the same struct could back the--output-json/--output-pairsidea from Consider designing bootc as a library to be used by installer applications bootc-dev/bootc#542. Errors are anErrorwithErrorKind::{InvalidOptions, Environment, Install}.install_t, the SELinux setup returns anEnvironmenterror instead. The source is always explicit (--source-imgrefsemantics), which already skips the mount namespace re-exec.crates/lib/examples/install-to-loopback.rs: a minimal installer that partitions and formats a loop disk with sfdisk/mkfs, then installs to it.What's out: to-disk, to-existing-root and reset. The composefs backend's outcome is wired up but not tested end to end. There's no byte-level pull progress. Status lines still go to stdout. Nothing is published to crates.io, and there's no C ABI or varlink.
Testing, on a 16-core RHEL 10 devspace (no fork CI):
just buildpassed, including the image'sbootc container lint --fatal-warnings.just unit-testspassed (bootc-lib: 287, including the 4 new ones), and so didjust validate.bcvk ephemeralVM, the example installedquay.io/centos-bootc/centos-bootc:stream10from an OCI directory to a 10G loopback disk. It reported all five steps, the outcome paths were right, andostree fsckwas clean. A systemd unit written into the reportedetcPaththen ran on first boot, under qemu with both SeaBIOS and OVMF, with SELinux enforcing.initrc_t(nomac_admin), the install failed withErrorKind::Environmentand no re-exec. Aftersetenforce 0it succeeded.--source-imgreffails on an ostree-booted host whose repo has several commits (bootc install to-existing-root fails when run on ostree based system bootc-dev/bootc#1343). That affects installers running from a bootc-based live environment. The SELinux check above hid/sysroot/ostreeto get past it.Open questions:
bootc-install) with a semver promise, separate from the internal bootc-lib, and published to crates.io?--progress-fdJSON event types, so the library and CLI share one protocol?xref bootc-dev#542
Generated-by: https://github.com/cgwalters/#llms
Review draft in cgwalters-forge, not upstream yet. This section is removed when the PR is opened upstream.
bootc-dev/bootc, basemainPVTI_lADOE9oHIs4BlJLczg-Ke4cTo review:
/promoteon a line of its own, to open it upstream, ready for review. Either covers only the commits pushed so far.Signed-off-by: Colin Walters <[email protected]>to the commits lacking it (the bot's and yours; anyone else's only if you ask), with you as committer./draftline (in the same comment or before) to open it upstream as a draft (/readyundoes that).