Skip to content
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

Make snapshotter root dynamic based on the reported mountpoint #1971

Merged
merged 5 commits into from
Feb 26, 2024

Conversation

davidcassany
Copy link
Contributor

@davidcassany davidcassany commented Feb 22, 2024

An attempt to fix #1972 and fix #1973

@davidcassany davidcassany requested a review from a team as a code owner February 22, 2024 16:21
@davidcassany davidcassany marked this pull request as draft February 22, 2024 16:21
Signed-off-by: David Cassany <dcassany@suse.com>
Signed-off-by: David Cassany <dcassany@suse.com>
@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 69.10995% with 59 lines in your changes are missing coverage. Please review.

Project coverage is 72.97%. Comparing base (e7630b0) to head (f4a70c1).

Files Patch % Lines
pkg/action/build-disk.go 55.04% 37 Missing and 12 partials ⚠️
pkg/snapshotter/btrfs.go 85.50% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1971      +/-   ##
==========================================
- Coverage   73.11%   72.97%   -0.15%     
==========================================
  Files          74       74              
  Lines        8671     8722      +51     
==========================================
+ Hits         6340     6365      +25     
- Misses       1819     1838      +19     
- Partials      512      519       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -70,6 +70,7 @@ if [ "${snapshotter}" == "btrfs" ]; then
echo "[Unit]"
echo "Before=initrd-root-fs.target"
echo "DefaultDependencies=no"
echo "RequiresMountsFor=/sysroot"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To ensure root is mounted first and so that appears a the top of /proc/mounts.

@@ -256,7 +256,7 @@ func (u *UpgradeAction) Run() (err error) {
}

// Init snapshotter
err = u.snapshotter.InitSnapshotter(u.spec.Partitions.State.MountPoint)
err = u.snapshotter.InitSnapshotter(u.spec.Partitions.State.MountPoint, u.spec.Partitions.EFI.MountPoint)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a draft to actually verify the fix, however I am starting to think that probably we should just define the method having u.spec.Partitions as input, instead of just the mountpoints.

@frelon any thoughts or ideas regarding this? We could even consider moving the responsability of mounting and setting the partitions as needed here in InitSnapshotter, now it just happens right before calling this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would make sense for the snapshotter to know about the EFI partition if we want to support having the kernel/initrd there in the future as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the latest implementation it takes the State partition struct and the EFI mountpoint. Adding to the EFI partition struct should be pretty trivial in the future too if needed. The actual mess was mostly with the state partition and its multiple mount points. For EFI having the appropriate path is enough for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice! :shipit:

Signed-off-by: David Cassany <dcassany@suse.com>
Signed-off-by: David Cassany <dcassany@suse.com>
Signed-off-by: David Cassany <dcassany@suse.com>
@davidcassany davidcassany marked this pull request as ready for review February 26, 2024 08:22
return nil
}

func findStateMount(runner v1.Runner, device string) (rootDir string, stateMount string, err error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only executed on Active and Passive modes and essentially checks the current state mountpoints and sets the current snapshot root to the snapshotter root and the sets the state mountpoint to the actual top level volume (this is the /run/initramfs/elemental-state mountpoint).

@davidcassany davidcassany merged commit e04b8c2 into rancher:main Feb 26, 2024
17 of 19 checks passed
@davidcassany davidcassany deleted the fix_upgrades_in_pod branch February 26, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants