Skip to content

Conversation

@Johan-Liebert1
Copy link
Collaborator

@Johan-Liebert1 Johan-Liebert1 commented Nov 21, 2025

Pulls in #1783

Handle the following cases we can encounter on bootc udpate and bootc switch

1. The verity is the same as that of the currently booted deployment
   - Nothing to do here in case of update as we're currently booted. But if we're switching
     then we update the target imageref in the .origin file for the deployment

2. The verity is the same as that of the staged deployment
   - Nothing to do, as we only get a "staged" deployment if we have
   /run/composefs/staged-deployment which is the last thing we create
   while upgrading

3. The verity is the same as that of the rollback deployment or any
   other deployment we have already deployed
   - Nothing to do since this is a rollback deployment which means
   this was unstaged at some point

4. The verity is not found
   - The update/switch might've been canceled before
   /run/composefs/staged-deployment was created, or at any other point
   in time, or it's a new one.

   Any which way, we can overwrite everything. In this case we remove
   all the staged bootloader entries, if any, and remove the entire
   state directory, as it would most probably be in an inconsistent
   state.

There is a lot here, and I managed to test the main code paths and the above four cases

Related: #1735

@bootc-bot bootc-bot bot requested a review from jmarrero November 21, 2025 10:59
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 idempotency for update and switch operations by checking if the target image is already present in some form. The logic is well-encapsulated in update.rs and shared between both commands. A significant and welcome part of this change is the refactoring of the Storage struct to manage the boot directory and ESP mount, which greatly cleans up the code and removes duplication across several files. Additionally, kernel argument handling is improved to preserve user changes during updates. The changes are well-structured and effectively achieve the PR's goal. I have left a couple of minor suggestions for improvement.

Cmdline::from(options)
}

_ => anyhow::bail!("Found NonEFI config"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message here is confusing. It says "Found NonEFI config", but it's in the _ arm of a match where the only other arm is BLSConfigType::NonEFI. This means it triggers for anything that is not NonEFI. A better error message would clarify that a NonEFI config was expected.

Suggested change
_ => anyhow::bail!("Found NonEFI config"),
_ => anyhow::bail!("Unsupported BLS config type: expected a NonEFI config"),

@Johan-Liebert1
Copy link
Collaborator Author

This will need a rebase after #1783 lands

Handle the following cases we can encounter on `bootc udpate`

1. The verity is the same as that of the currently booted deployment
   - Nothing to do here in case of update as we're currently booted. But if we're switching
     then we update the target imageref in the .origin file for the deployment

2. The verity is the same as that of the staged deployment
   - Nothing to do, as we only get a "staged" deployment if we have
   /run/composefs/staged-deployment which is the last thing we create
   while upgrading

3. The verity is the same as that of the rollback deployment or any
   other deployment we have already deployed
   - Nothing to do since this is a rollback deployment which means
   this was unstaged at some point

4. The verity is not found
   - The update/switch might've been canceled before
   /run/composefs/staged-deployment was created, or at any other point
   in time, or it's a new one.

   Any which way, we can overwrite everything. In this case we remove
   all the staged bootloader entries, if any, and remove the entire
   state directory, as it would most probably be in an inconsistent
   state.

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Similar to how we handle bootc update

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
@Johan-Liebert1
Copy link
Collaborator Author

Johan-Liebert1 commented Nov 25, 2025

Thought the TMT failure was a flake and reran the test, but it seems like reboot seems to be failing on centos-10?

    Cause number 1:

        Command 'reboot' returned 1.

        # stderr (1 lines)
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Call to Reboot failed: Access denied
        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


match boot_type {
BootType::Bls => {
boot_digest = Some(setup_composefs_bls_boot(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only tangential to this but I think we want to more carefully tease apart setup_composefs_bls_boot so that we don't need the enum anymore.

// remote_image is the exact same image as the one currently booted, but
// they are wanting to change the target
//
// We could simply update the image origin file here
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are doing that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, we are doing that. This comment was for implementation reference

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in #1811

@cgwalters cgwalters merged commit b33cb5c into bootc-dev:main Nov 25, 2025
35 of 37 checks passed
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.

2 participants