cli: Make loader-entries unavailable when ostree lacks bootconfig-extra - #2485
Merged
Merged
Conversation
jmarrero
force-pushed
the
gate-ostree
branch
from
September 22, 2026 12:04
0e1bed4 to
20425f9
Compare
cgwalters
previously approved these changes
Sep 22, 2026
cgwalters
left a comment
Collaborator
There was a problem hiding this comment.
I think this is OK, but what we really want in the future is a varlink api for stuff like this.
| fn check_host_feature_gates(opt: &Opt, bootconfig_extra: bool) -> Result<(), clap::Error> { | ||
| if matches!(opt, Opt::LoaderEntries(_)) && !bootconfig_extra { | ||
| let err = crate::loader_entries::unsupported_ostree_error(); | ||
| return Err(Opt::command().error(clap::error::ErrorKind::InvalidSubcommand, err)); |
Collaborator
There was a problem hiding this comment.
In order to allow a caller to distinguish "some other error" from "operation not supported" I think we could return an exit code of 77 or so which has some precendent for "skipped".
…xtra `bootc loader-entries set-options-for-source` only works with libostree >= 2026.1, which added the `bootconfig-extra` serialization that carries `x-options-source-*` keys through a staged deployment. Until now the subcommand was advertised in `bootc --help` on every host and only failed at runtime. That matters for TuneD: its bootc integration probes for the feature by running `bootc loader-entries set-options-for-source --help` and checking the exit status, and only falls back to its rpm-ostree/GRUB2 path when that fails. See <redhat-performance/tuned#827>. Merely hiding the subcommand from help would not be enough, since a hidden clap subcommand still answers `--help` with exit status 0. So detect the feature via `ostree_check_version()` at runtime and, when it is missing, make the subcommand unavailable: hide it from `--help` and reject any invocation of it before parsing, `--help` included, with an error naming the required ostree version. That rejection exits with status 77 (the "skipped" convention) rather than clap's usage-error 2, so a caller can tell "not supported on this host" from a mistake. The gate is applied only at argument-parsing time, not in `Opt::command()`. That keeps the man page sync (`dump-cli-json`) and `bootc completion` (run by the Makefile at package build time) describing the full CLI, so generated docs and completions don't change depending on the ostree version of whichever host built them. Assisted-by: AI Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
jmarrero
force-pushed
the
gate-ostree
branch
from
September 22, 2026 15:05
20425f9 to
d02d5e4
Compare
jmarrero
marked this pull request as ready for review
September 22, 2026 15:27
cgwalters
approved these changes
Sep 22, 2026
cgwalters
enabled auto-merge (rebase)
September 22, 2026 19:07
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.
bootc loader-entries set-options-for-sourceonly works with libostree >= 2026.1, which added thebootconfig-extraserialization that carriesx-options-source-*keys through a staged deployment. Until now the subcommand was advertised inbootc --helpon every host and only failed at runtime.That matters for TuneD: its bootc integration probes for the feature by running
bootc loader-entries set-options-for-source --helpand checking the exit status, and only falls back to its rpm-ostree/GRUB2 path when that fails (see redhat-performance/tuned#827). Merely hiding the subcommand from help would not be enough, since a hidden clap subcommand still answers--helpwith exit status 0.So detect the feature via
ostree_check_version()at runtime and, when it is missing, make the subcommand unavailable: hide it from--help, disable--helpon it and its children so a probe fails, and reject an actual invocation after parsing with an error naming the required ostree version.The gate is applied only at argument-parsing time, not in
Opt::command(), so the man page sync (dump-cli-json) andbootc completionkeep describing the full CLI regardless of the ostree version of the host that built the package.Testing
Built the RPM against CentOS Stream 9 and ran TuneD 2.28.0 (with redhat-performance/tuned#892) on two bcvk VMs:
bootconfig-extra):loader-entriesis absent frombootc --help, the probe exits 2 and a direct invocation is rejected.tuned-adm profilewith a[bootloader] cmdline=went through rpm-ostree (Initiated txn KernelArgs for client(… unit:tuned.service)), no bootc lines in the TuneD log; the kargs are on the cmdline after reboot, a profile switch removes them via rpm-ostree, andbootc rollbackback into the tuned deployment restores them.x-options-source-tunedkey are in the booted BLS entry.Unit test
cli::tests::test_host_feature_gatescovers the gate.Assisted-by: AI
I am knowledgeable in this problem domain and tested the change on both ostree versions as described above.