Skip to content

Conversation

@Johan-Liebert1
Copy link
Collaborator

Changes

Move all composefs-native related code to crates/lib/src/bootc_composefs. This might help us to spot diff while merging, also should hopefully create less conflicts on subsequent

Gate composefs-native behind composefs-backend flag

Refactor to use #[cfg(feature = "composefs-backend")] to gate composefs native features behind the flag.

Gate the following features

  • --composefs-native and its corresponding cli args
  • Installing/Switching/Upgrading/RollingBack of composefs native system
  • Create separate install, rollback functions for ostree for a bit cleaner of a setup

Move all composefs-native related stuff into `lib/src/bootc_composefs`.
This might help us to spot diff while merging into main, also should
hopefully create less conflicts

Signed-off-by: Pragyan Poudyal <[email protected]>
Refactor to use `#[cfg(feature = "composefs-backend")]` to gate
composefs native features behind the flag.

Gate the following features
- `--composefs-native` and its corresponding cli args
- Installing/Switching/Upgrading/RollingBack of composefs native system
- Create separate install, rollback functions for ostree for a bit
  cleaner of a setup

Signed-off-by: Pragyan Poudyal <[email protected]>
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 is a significant and well-executed refactoring that moves all composefs-native related code into a dedicated crates/lib/src/bootc_composefs module and gates it behind a composefs-backend feature flag. The changes are clean and align with the stated goals. I've identified a high-severity bug in switch.rs where the transport protocol is hardcoded, which would prevent switching to images from non-docker registries. Additionally, I've found a couple of minor typos in error messages and suggested a small refactoring in repo.rs for improved efficiency and code clarity. Overall, great work on this refactoring.

Comment on lines 71 to 86
let repo = open_composefs_repo(&rootfs_dir).context("Opening compoesfs repo")?;

let (id, verity) =
composefs_oci_pull(&Arc::new(repo), &format!("{transport}:{image}"), None, None)
.await
.context("Pulling composefs repo")?;

tracing::debug!(
"id = {id}, verity = {verity}",
id = hex::encode(id),
verity = verity.to_hex()
);

let repo = open_composefs_repo(&rootfs_dir)?;
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
.context("Failed to create composefs filesystem")?;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To avoid opening the composefs repository twice, you can create an Arc for the repository and reuse it. This is slightly more efficient and makes the code cleaner. This change also fixes a typo in the error message on line 71.

Suggested change
let repo = open_composefs_repo(&rootfs_dir).context("Opening compoesfs repo")?;
let (id, verity) =
composefs_oci_pull(&Arc::new(repo), &format!("{transport}:{image}"), None, None)
.await
.context("Pulling composefs repo")?;
tracing::debug!(
"id = {id}, verity = {verity}",
id = hex::encode(id),
verity = verity.to_hex()
);
let repo = open_composefs_repo(&rootfs_dir)?;
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
.context("Failed to create composefs filesystem")?;
let repo = Arc::new(open_composefs_repo(&rootfs_dir).context("Opening composefs repo")?);
let (id, verity) =
composefs_oci_pull(&repo, &format!("{transport}:{image}"), None, None)
.await
.context("Pulling composefs repo")?;
tracing::debug!(
"id = {id}, verity = {verity}",
id = hex::encode(id),
verity = verity.to_hex()
);
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
.context("Failed to create composefs filesystem")?;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We return the repo right now and most functions accept a non Arc repo

Fix typo in error message
Unhardcode transport while pulling a composefs repository on
switch

Signed-off-by: Pragyan Poudyal <[email protected]>
@travier
Copy link
Contributor

travier commented Sep 9, 2025

Might be worth opening the same PR but against main directly if we think we are ready to merge this gated by a feature flag. Might be easier to read the diff.

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

I'm tentatively OK as is but there's a lot of followup here

Comment on lines +1316 to +1324
#[cfg(feature = "composefs-backend")]
if composefs_booted()?.is_some() {
composefs_rollback().await?
} else {
rollback(&opts).await?
}

#[cfg(not(feature = "composefs-backend"))]
rollback(&opts).await?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This code pattern is the problem in a nutshell

  • It's duplicative and easy to mess up in later refactoring
  • As we move forward I think we should be thinking of composefs as the core/future and so we may want to actually start naming things ostree_ as a prefix instead of prefixing everything with composefs_
  • But really more generally we should operate in terms of methods
  • I want to move the composefs repo loading into mod storage

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed with all the points. This was best effort that didn't require any other huge overhaul

@cgwalters cgwalters merged commit bda61be into bootc-dev:composefs-backend Sep 9, 2025
21 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.

3 participants