Skip to content

Commit 93aad24

Browse files
Gabriel Beims Bräscheryadvr
authored andcommitted
storage: Handle RBD snapshot deletion (#3615)
When deleting volume snapshots, only records in the database are deleted, and snapshots are not deleted on the main storage. Fixes: #3586
1 parent 29e1bbc commit 93aad24

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/snapshot/CephSnapshotStrategy.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,18 @@ public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) {
5656
return StrategyPriority.CANT_HANDLE;
5757
}
5858

59-
if (SnapshotOperation.REVERT.equals(op) && isSnapshotStoredOnRbdStoragePool(snapshot)) {
59+
if (!isSnapshotStoredOnRbdStoragePool(snapshot)) {
60+
return StrategyPriority.CANT_HANDLE;
61+
}
62+
63+
if (SnapshotOperation.REVERT.equals(op)) {
6064
return StrategyPriority.HIGHEST;
6165
}
66+
67+
if (SnapshotOperation.DELETE.equals(op)) {
68+
return StrategyPriority.HIGHEST;
69+
}
70+
6271
return StrategyPriority.CANT_HANDLE;
6372
}
6473

engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/snapshot/CephSnapshotStrategyTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ private void configureAndVerifyCanHandle(Date removed, boolean isSnapshotStoredO
8787
StrategyPriority strategyPriority = cephSnapshotStrategy.canHandle(snapshot, snapshotOps[i]);
8888
if (snapshotOps[i] == SnapshotOperation.REVERT && isSnapshotStoredOnRbdStoragePool) {
8989
Assert.assertEquals(StrategyPriority.HIGHEST, strategyPriority);
90+
} else if (snapshotOps[i] == SnapshotOperation.DELETE && isSnapshotStoredOnRbdStoragePool) {
91+
Assert.assertEquals(StrategyPriority.HIGHEST, strategyPriority);
9092
} else {
9193
Assert.assertEquals(StrategyPriority.CANT_HANDLE, strategyPriority);
9294
}

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
8282
@Override
8383
public Map<String, String> getCapabilities() {
8484
Map<String, String> caps = new HashMap<String, String>();
85-
caps.put(DataStoreCapabilities.VOLUME_SNAPSHOT_QUIESCEVM.toString(), "false");
85+
caps.put(DataStoreCapabilities.VOLUME_SNAPSHOT_QUIESCEVM.toString(), Boolean.FALSE.toString());
8686
return caps;
8787
}
8888

0 commit comments

Comments
 (0)