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

Fix volume rename if cluster desination target is set #12410

Merged
merged 2 commits into from
Oct 18, 2023
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
5 changes: 3 additions & 2 deletions lxc/storage_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,9 @@ func (c *cmdStorageVolumeMove) Run(cmd *cobra.Command, args []string) error {
return fmt.Errorf(i18n.G("No storage pool for target volume specified"))
}

// Rename volume if both remotes and pools of source and target are equal.
if srcRemote == dstRemote && srcVolPool == dstVolPool {
// Rename volume if both remotes and pools of source and target are equal
// and no destination cluster member name is set.
if srcRemote == dstRemote && srcVolPool == dstVolPool && c.storageVolume.flagDestinationTarget == "" {
var args []string

if srcRemote != "" {
Expand Down
10 changes: 10 additions & 0 deletions test/suites/clustering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,19 @@ test_clustering_storage() {
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume copy pool1/vol1 pool1/vol1 --target=node1 --destination-target=node2
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume copy pool1/vol1 pool1/vol1 --target=node1 --destination-target=node2 --refresh

# Check renaming storage volume works.
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume create pool1 vol2 --target=node1
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume move pool1/vol2 pool1/vol3 --target=node1
LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show pool1 vol3 | grep -q node1
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume move pool1/vol3 pool1/vol2 --target=node1 --destination-target=node2
LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show pool1 vol2 | grep -q node2
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume rename pool1 vol2 vol3 --target=node2
LXD_DIR="${LXD_TWO_DIR}" lxc storage volume show pool1 vol3 | grep -q node2

# Delete pool and check cleaned up.
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete pool1 vol1 --target=node1
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete pool1 vol1 --target=node2
LXD_DIR="${LXD_ONE_DIR}" lxc storage volume delete pool1 vol3 --target=node2
LXD_DIR="${LXD_TWO_DIR}" lxc storage delete pool1
! stat "${LXD_ONE_SOURCE}/containers" || false
! stat "${LXD_TWO_SOURCE}/containers" || false
Expand Down
Loading