Skip to content

Commit 8ac2501

Browse files
Gabriel Beims Bräscheryadvr
authored andcommitted
ceph: fix issue #3590 'Revert Ceph/RBD Snapshot' (#3605)
Fixes issue #3590 by using the last element on the array from the snapshot "path" String for retrieving the snapshot id. Additionally, it uses the volumePath as the volume id which should always be the correct value. The error raised on issue #3590 was related to the wrong use of variable "path" where in some cases had a different set of substrings. The proposed change has been tested and evaluated. The values used for openning the RBD connection and executing the rollback were stable on the tests. Runned rollback on multiple snapshots and could start the VM with the content matching the ROOT reverted snapshot.
1 parent ae61bfe commit 8ac2501

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRevertSnapshotCommandWrapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,16 @@ public Answer execute(final RevertSnapshotCommand command, final LibvirtComputin
8686
rados.connect();
8787

8888
String[] rbdPoolAndVolumeAndSnapshot = snapshotRelPath.split("/");
89+
int snapshotIndex = rbdPoolAndVolumeAndSnapshot.length - 1;
90+
String rbdSnapshotId = rbdPoolAndVolumeAndSnapshot[snapshotIndex];
8991

9092
IoCTX io = rados.ioCtxCreate(primaryPool.getSourceDir());
9193
Rbd rbd = new Rbd(io);
92-
RbdImage image = rbd.open(rbdPoolAndVolumeAndSnapshot[1]);
9394

94-
s_logger.debug(String.format("Attempting to rollback RBD snapshot [name:%s], [pool:%s], [volumeid:%s], [snapshotid:%s]", snapshot.getName(),
95-
rbdPoolAndVolumeAndSnapshot[0], rbdPoolAndVolumeAndSnapshot[1], rbdPoolAndVolumeAndSnapshot[2]));
96-
image.snapRollBack(rbdPoolAndVolumeAndSnapshot[2]);
95+
s_logger.debug(String.format("Attempting to rollback RBD snapshot [name:%s], [volumeid:%s], [snapshotid:%s]", snapshot.getName(), volumePath, rbdSnapshotId));
96+
97+
RbdImage image = rbd.open(volumePath);
98+
image.snapRollBack(rbdSnapshotId);
9799

98100
rbd.close(image);
99101
rados.ioCtxDestroy(io);

0 commit comments

Comments
 (0)