Skip to content

Conversation

@KyleGospo
Copy link

@KyleGospo KyleGospo commented Nov 6, 2025

Fixes issue with bootc switch on Debian, Arch, and other distros.
Previous behavior would error out with: error: Composefs Switching: Writing composefs state: Failed to create symlink /var: File exists (os error 17)

Here's proof of functionality:
image

Coauthored-by: Tulip Blossom [email protected] @tulilirockz

…e with bootc switch on other distros.

Coauthored-by: Tulip Blossom <[email protected]>
Signed-off-by: Kyle Gospodnetich <[email protected]>
@bootc-bot bootc-bot bot requested a review from gursewak1997 November 6, 2025 03:02
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 aims to fix an issue where creating a symlink for /var fails if it already exists. The proposed change checks for the existence of the path before creating the symlink. However, the use of Path::exists() is problematic as it follows symlinks and returns false for broken symlinks, which would cause the code to attempt to create the symlink again and fail. I've suggested a more robust way to handle this by attempting the operation and ignoring the AlreadyExists error, which also avoids a potential race condition.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Kyle Gospodnetich <[email protected]>
@Johan-Liebert1
Copy link
Collaborator

The issue here seems to be that switch is somehow outputting the same verity for two images? Or was the switch cancelled after the /var symlink was created? In the latter case I think we'd need to remove the state dir and recreate it. The former case feels unlikely.

A reproducible example would be great

@KyleGospo
Copy link
Author

KyleGospo commented Nov 6, 2025

The issue here seems to be that switch is somehow outputting the same verity for two images? Or was the switch cancelled after the /var symlink was created? In the latter case I think we'd need to remove the state dir and recreate it. The former case feels unlikely.

A reproducible example would be great

Any image at https://github.com/bootcrew/ will reproduce this (I recommend https://github.com/bootcrew/debian-bootc), the issue is that the /var link already exists when this is fired off from what I can tell.

To reproduce it, boot one of their images and then attempt to bootc switch to the actual ghcr.io link. It will silently fail, and then on reboot you'll be brought to the original image.

@Johan-Liebert1
Copy link
Collaborator

To reproduce it, boot one of their images and then attempt to bootc switch to the actual ghcr.io link. It will silently fail, and then on reboot you'll be brought to the original image.

So we build the image locally and then switch to the remote image? If there are no differences between the images, then they will both output the same verity, for which we already have the state dir. But, in your screenshot I can see the images have different verity...

Anyway, this is an issue, and simply checking for /var symlink existing is not good as we might overwrite everything else in the state dir

@Johan-Liebert1
Copy link
Collaborator

One solution I had in mind for this is to just update the .origin file if the switched image has the same verity as any one of the image present. As that's basically what were doing, updating the target imgref, but nothing in the image has actually changed

@KyleGospo
Copy link
Author

To reproduce it, boot one of their images and then attempt to bootc switch to the actual ghcr.io link. It will silently fail, and then on reboot you'll be brought to the original image.

So we build the image locally and then switch to the remote image? If there are no differences between the images, then they will both output the same verity, for which we already have the state dir. But, in your screenshot I can see the images have different verity...

Anyway, this is an issue, and simply checking for /var symlink existing is not good as we might overwrite everything else in the state dir

If you've got a concept for how to fix this the proper way I am happy to test it against this as much as you need.

Images could differ from local build and the ghcr remote just based on timing and what changes upstream, so this isn't just a need to change origin.

@cgwalters cgwalters added the area/composefs Issues related to composefs label Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/composefs Issues related to composefs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants