Skip to content

Commit f2d6356

Browse files
authored
Update error message when no snapshot strategy is found while creating snapshot (#11455)
1 parent 5a90da3 commit f2d6356

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,6 +2795,8 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) {
27952795
} catch (CloudRuntimeException cre) {
27962796
logger.error("Take snapshot: {} failed", volume, cre);
27972797
throw cre;
2798+
} catch (UnsupportedOperationException ex) {
2799+
throw ex;
27982800
} catch (Exception e) {
27992801
if (logger.isDebugEnabled()) {
28002802
logger.debug("unknown exception while taking snapshot for volume {} was caught", volume, e);

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,10 +3814,8 @@ protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) throws S
38143814

38153815
@Override
38163816
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "taking snapshot", async = true)
3817-
public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm,
3818-
Snapshot.LocationType locationType, boolean asyncBackup, Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication)
3819-
3820-
throws ResourceAllocationException {
3817+
public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm, Snapshot.LocationType locationType, boolean asyncBackup,
3818+
Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication) throws ResourceAllocationException {
38213819
final Snapshot snapshot = takeSnapshotInternal(volumeId, policyId, snapshotId, account, quiescevm, locationType, asyncBackup, zoneIds, poolIds, useStorageReplication);
38223820
if (snapshot != null && MapUtils.isNotEmpty(tags)) {
38233821
taggedResourceService.createTags(Collections.singletonList(snapshot.getUuid()), ResourceTag.ResourceObjectType.Snapshot, tags, null);

server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,8 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
16211621
if (snapshotStrategy == null) {
16221622
_snapshotDao.remove(snapshotId);
16231623
logger.debug("No strategy found for creation of snapshot [{}], removing its record from the database.", snapshot);
1624-
throw new CloudRuntimeException(String.format("Can't find snapshot strategy to deal with snapshot:%s", snapshot.getSnapshotVO()));
1624+
throw new UnsupportedOperationException(String.format("Unable to find a snapshot strategy to create snapshot [%s] of volume [%s]. Please check the logs.",
1625+
snapshot.getSnapshotVO(), volume.getUuid()));
16251626
}
16261627

16271628
SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot);
@@ -1672,7 +1673,7 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
16721673
} catch (Exception e) {
16731674
logger.debug("post process snapshot failed", e);
16741675
}
1675-
} catch (CloudRuntimeException cre) {
1676+
} catch (CloudRuntimeException | UnsupportedOperationException cre) {
16761677
if (logger.isDebugEnabled()) {
16771678
logger.debug("Failed to create snapshot" + cre.getLocalizedMessage());
16781679
}

0 commit comments

Comments
 (0)