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

Ceph RBD: Restore the filesystems UUID on the volume #12745

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions lxd/storage/drivers/driver_ceph_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1798,21 +1798,16 @@ func (d *ceph) RestoreVolume(vol Volume, snapshotName string, op *operations.Ope
return err
}

snapVol, err := vol.NewSnapshot(snapshotName)
if err != nil {
return err
}

// Map the RBD volume.
devPath, err := d.rbdMapVolume(snapVol)
devPath, err := d.rbdMapVolume(vol)
if err != nil {
return err
}

defer func() { _ = d.rbdUnmapVolume(snapVol, true) }()
defer func() { _ = d.rbdUnmapVolume(vol, true) }()

// Re-generate the UUID.
err = d.generateUUID(snapVol.ConfigBlockFilesystem(), devPath)
err = d.generateUUID(vol.ConfigBlockFilesystem(), devPath)
if err != nil {
return err
}
Expand Down
19 changes: 18 additions & 1 deletion test/suites/storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,25 @@ test_storage() {
fi
lxc delete --force uuid1
lxc delete --force uuid2
lxc image delete testimage

# Test UUID re-generation in case of restore.
lxc init testimage uuid1 -s "${POOL}"
lxc snapshot uuid1
lxc start uuid1
if [ "$lxd_backend" = "lvm" ]; then
uuid="$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid1)"
elif [ "$lxd_backend" = "ceph" ]; then
uuid="$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid1)"
fi
lxc restore uuid1 snap0
if [ "$lxd_backend" = "lvm" ]; then
[ "$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid1)" != "$uuid" ]
elif [ "$lxd_backend" = "ceph" ]; then
[ "$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid1)" != "$uuid" ]
fi
lxc delete --force uuid1

lxc image delete testimage
lxc storage delete "$btrfs_storage_pool"
fi
ensure_import_testimage
Expand Down
Loading