You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fixes snapshot deletion
* Remove legacy '@component', it is not necessary in this bean/class.
* Fix log message missing %d and remove snapshot on DB
* Remove "dummy" boolean return statement
* Manage snapshot deletion for KVM + NFS (primary storage)
* checkstyle trailing spaces
* rename options strings to *_OPTION
* Fix typo on deleteSnapshotOnSecondaryStorage and enhance log message
* Move the snapshotDao.remove(snapshotId); (apache#4006)
* Fix deletesnapshot worflow to handle both snapshots created in primary storage and snapshots backed up to secondary storage
* Fix extra space
* refactor out separate handling methods for secondary and primary (reducing returns)
* return false on unexpected error or log when expected
* != instead of ==
* secondary instead of backup storage
* init to null
* Handle snapshot deletion on primary storage. When primary store ref not found for snapshot do not fail the operation.
* Fix debug levels on log messages
Co-authored-by: GabrielBrascher <gabriel@apache.org>
Co-authored-by: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com>
Co-authored-by: Harikrishna Patnala <harikrishna.patnala@gmail.com>
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
// Here we handle snapshots which are to be deleted but are not marked as destroyed yet.
288
+
// This may occur for instance when they are created only on primary because
289
+
// snapshot.backup.to.secondary was set to false.
290
+
if (snapshotOnPrimaryInfo == null) {
291
+
if (s_logger.isDebugEnabled()) {
292
+
s_logger.debug(String.format("Snapshot (id: %d) not found on primary storage, skipping snapshot deletion on primary and marking it destroyed", snapshotId));
String.format("Failed to find/delete snapshot (id: %d) on secondary storage. Still necessary to check and delete snapshot on primary storage.",
328
+
snapshotId));
329
+
} else {
330
+
s_logger.debug(String.format("Snapshot (id: %d) has been deleted on secondary storage.", snapshotId));
316
331
}
332
+
} catch (NoTransitionExceptione) {
333
+
s_logger.debug("Failed to set the state to destroying: ", e);
334
+
// deletedOnSecondary remain null
317
335
}
318
-
} catch (Exceptione) {
319
-
s_logger.debug("Failed to delete snapshot: ", e);
336
+
}
337
+
returndeletedOnSecondary;
338
+
}
339
+
340
+
/**
341
+
* Deletes the snapshot on secondary storage.
342
+
* It can return false when the snapshot was stored on primary storage and not backed up on secondary; therefore, the snapshot should also be deleted on primary storage even when this method returns false.
* Deletes the snapshot on primary storage. It returns true when the snapshot was not found on primary storage; </br>
365
+
* In case of failure while deleting the snapshot, it will throw one of the following exceptions: CloudRuntimeException, InterruptedException, or ExecutionException. </br>
s_logger.debug(String.format("Snapshot reference is found on primary storage for snapshot id: %d, performing snapshot deletion on primary", snapshotId));
372
+
}
373
+
if (snapshotSvr.deleteSnapshot(snapshotOnPrimaryInfo)) {
s_logger.debug(String.format("Successfully deleted snapshot id: %d on primary storage", snapshotId));
378
+
}
379
+
returntrue;
324
380
}
325
-
returnfalse;
381
+
} else {
382
+
if (s_logger.isDebugEnabled()) {
383
+
s_logger.debug(String.format("Snapshot reference is not found on primary storage for snapshot id: %d, skipping snapshot deletion on primary", snapshotId));
384
+
}
385
+
returntrue;
326
386
}
387
+
returnfalse;
388
+
}
327
389
328
-
returntrue;
390
+
/**
391
+
* Returns true if the snapshot volume is on primary storage.
Copy file name to clipboardExpand all lines: engine/storage/snapshot/src/main/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
0 commit comments