-
Notifications
You must be signed in to change notification settings - Fork 156
lib: Add --from-downloaded flag for bootc upgrade #1846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new --apply-staged flag to bootc upgrade, allowing users to apply a previously downloaded update without checking for a newer one from the registry. This is a well-implemented feature that enhances scheduled maintenance workflows. The code changes are clear, and the documentation and tests have been updated accordingly. I have one minor suggestion to refactor a small part of the new logic to improve code clarity and efficiency.
crates/lib/src/cli.rs
Outdated
| let staged_deployment = storage | ||
| .get_ostree()? | ||
| .staged_deployment() | ||
| .ok_or_else(|| anyhow::anyhow!("No staged deployment found"))?; | ||
|
|
||
| if staged_deployment.is_finalization_locked() { | ||
| storage | ||
| .get_ostree()? | ||
| .change_finalization(&staged_deployment)?; | ||
| println!("Staged deployment will now be applied on reboot"); | ||
| } else { | ||
| println!("Staged deployment is already set to apply on reboot"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid calling storage.get_ostree()? multiple times, you can store its result in a variable and reuse it. This improves readability and is slightly more efficient.
let ostree = storage.get_ostree()?;
let staged_deployment = ostree
.staged_deployment()
.ok_or_else(|| anyhow::anyhow!("No staged deployment found"))?;
if staged_deployment.is_finalization_locked() {
ostree.change_finalization(&staged_deployment)?;
println!("Staged deployment will now be applied on reboot");
} else {
println!("Staged deployment is already set to apply on reboot");
}
crates/lib/src/cli.rs
Outdated
| /// The deployment will be applied on the next shutdown or reboot. Use with --apply to | ||
| /// reboot immediately. | ||
| #[clap(long, conflicts_with_all = ["check", "download_only"])] | ||
| pub(crate) apply_staged: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--apply-staged --apply "stutters" i.e. at first it looks redundant but it's not.
How about calling this --enqueue?
But maybe we can also add a shorthand --enqueue --apply ➡️ --apply-from-download ?
Or maybe the option is called --from-downloaded ? I kind of like that more than --enqueue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, --from-downloaded sounds more natural, updated.
3a74eed to
34e1e8f
Compare
34e1e8f to
af115f4
Compare
Add a new --from-downloaded flag to bootc upgrade that allows users to unlock a staged deployment created with --download-only without fetching updates from the container image source. This provides a way to apply already-downloaded updates without triggering a fetch operation, which is useful for scheduled maintenance workflows where the update was downloaded earlier and should now be applied at a scheduled time. Usage: # Download update without applying bootc upgrade --download-only # Later: Apply the staged update (without fetching from image source) bootc upgrade --from-downloaded # Or: Apply staged update and reboot immediately bootc upgrade --from-downloaded --apply The flag conflicts with --check and --download-only as those operations have different purposes. It can be combined with --apply to immediately reboot after unlocking the staged deployment. This commit also updates the documentation (upgrades.md) to describe all three ways to apply a download-only update, and updates the download-only test case (test-25) to use --from-downloaded instead of plain 'bootc upgrade' when clearing the download-only flag. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Wei Shi <[email protected]>
af115f4 to
c9ec041
Compare
Add a new --from-downloaded flag to bootc upgrade that allows users to unlock a staged deployment created with --download-only without checking for newer updates from the registry.
This provides a way to apply already-downloaded updates without triggering a registry check, which is useful for scheduled maintenance workflows where the update was downloaded earlier and should now be applied at a scheduled time.
Usage:
Download update without applying
bootc upgrade --download-only
Later: Apply the staged update (no registry check)
bootc upgrade --from-downloaded
Or: Apply staged update and reboot immediately
bootc upgrade --from-downloaded --apply
The flag conflicts with --check and --download-only as those operations have different purposes. It can be combined with --apply to immediately reboot after unlocking the staged deployment.
This commit also updates the documentation (upgrades.md) to describe all three ways to apply a download-only update, and updates the download-only test case (test-25) to use --apply-staged instead of plain
bootc upgradewhen clearing the download-only flag.Assisted-by: Claude Code (Sonnet 4.5)