Skip to content

Commit

Permalink
Do not migrate legacy images if snapshots are already present (#1990)
Browse files Browse the repository at this point in the history
* Do not migrate legacy images if snapshots are already present

This commit prevents executing the legacy images migration logic
if snapshotter already finds available snapshots. This mostly
means the migration was already executed and legacy images
had already a chance to be converted into snapshots.

* Fix btrfs snapshotter image variable

Signed-off-by: David Cassany <dcassany@suse.com>
  • Loading branch information
davidcassany authored Mar 6, 2024
1 parent b266360 commit c4bea71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/features/embedded/grub-config/etc/elemental/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ function set_volume {
set btrfs_relative_path="y"
set volume="${root}"
if [ -n "${1}" ]; then
set img=${1}
btrfs-mount-subvol ($root) / @/.snapshots/${1}/snapshot
set img=@/.snapshots/${1}/snapshot
btrfs-mount-subvol ($root) / ${img}
fi
elif [ -z "${1}" ]; then
set_loopdevice /.snapshots/active
Expand Down
4 changes: 4 additions & 0 deletions pkg/snapshotter/loopdevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ func (l *LoopDevice) legacyImageToSnapsot(image string) error {
l.cfg.Logger.Errorf("failed setting the snaphsot ID for legacy images: %v", err)
return err
}
if id > 1 {
l.cfg.Logger.Debugf("Skipping legacy image migration, some snapshot already found in the system")
return nil
}
l.cfg.Logger.Debugf("Migrating image %s to snapshot %d", image, id)

snapPath := filepath.Join(l.rootDir, loopDeviceSnapsPath, strconv.FormatInt(int64(id), 10))
Expand Down

0 comments on commit c4bea71

Please sign in to comment.