Skip to content

Commit 23c1419

Browse files
committed
<fix>[storage]: mock ceph snap protect
before delete ceph volum, it will check volume snapshot exists Resolves: ZSTAC-56100 Change-Id: I726664777a68676a6c696e73627274616678646f
1 parent 6d48624 commit 23c1419

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

storage/src/main/java/org/zstack/storage/snapshot/reference/VolumeSnapshotReferenceTreeBase.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.zstack.header.storage.primary.GetVolumeBackingChainFromPrimaryStorageMsg;
2121
import org.zstack.header.storage.primary.GetVolumeBackingChainFromPrimaryStorageReply;
2222
import org.zstack.header.storage.primary.PrimaryStorageConstant;
23-
import org.zstack.header.storage.snapshot.VolumeSnapshotVO;
2423
import org.zstack.header.storage.snapshot.reference.DeleteVolumeSnapshotReferenceLeafMsg;
2524
import org.zstack.header.storage.snapshot.reference.DeleteVolumeSnapshotReferenceLeafReply;
2625
import org.zstack.header.storage.snapshot.reference.VolumeSnapshotReferenceInventory;
@@ -103,7 +102,7 @@ private void deleteSnapshotRefLeaf(DeleteVolumeSnapshotReferenceLeafMsg msg, Com
103102
Set<String> otherLeafDirectBackingInstallUrls = msg.getOtherLeafs().stream()
104103
.map(VolumeSnapshotReferenceInventory::getDirectSnapshotInstallUrl)
105104
.collect(Collectors.toSet());
106-
if (hasSameVolumeResource(msg.getLeaf().getDirectSnapshotInstallUrl(), otherLeafDirectBackingInstallUrls)) {
105+
if (otherLeafDirectBackingInstallUrls.contains(msg.getLeaf().getDirectSnapshotInstallUrl())) {
107106
logger.debug(String.format("other leafs has the same direct backing, skip delete leaf: [%d]", msg.getLeaf().getId()));
108107
completion.success();
109108
return;
@@ -191,7 +190,7 @@ public void run(FlowTrigger trigger, Map data) {
191190
.filter(e -> !e.getKey().equals(startPath))
192191
.flatMap(e -> e.getValue().stream()).collect(Collectors.toSet());
193192

194-
filterDeletePaths(toDeletePaths, usedByOthersPaths);
193+
toDeletePaths.removeAll(usedByOthersPaths);
195194
logger.debug("delete snapshot reference leafs: " + toDeletePaths);
196195
trigger.next();
197196
}

testlib/src/main/java/org/zstack/testlib/CephPrimaryStorageSpec.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,10 @@ class CephPrimaryStorageSpec extends PrimaryStorageSpec {
744744
if (vfsPath.contains("@")) {
745745
vfs.delete(vfsPath)
746746
String volPath = vfsPath.split("@")[0]
747-
//assert getSnapshotPaths(vfs, volPath).isEmpty() : "the volume[%s] has snapshots, cannot delete it".format(volPath)
747+
assert getSnapshotPaths(vfs, volPath).isEmpty() : "the volume[%s] has snapshots, cannot delete it".format(volPath)
748748
vfs.delete(volPath)
749749
} else {
750-
//assert getSnapshotPaths(vfs, vfsPath).isEmpty() : "the volume[%s] has snapshots, cannot delete it".format(vfsPath)
750+
assert getSnapshotPaths(vfs, vfsPath).isEmpty() : "the volume[%s] has snapshots, cannot delete it".format(vfsPath)
751751
vfs.delete(vfsPath)
752752
}
753753
}

testlib/src/main/java/org/zstack/testlib/vfs/CephRaw.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class CephRaw extends Raw {
4444
}
4545

4646
parent = null
47+
update()
4748
return this
4849
}
4950
}

0 commit comments

Comments
 (0)