Skip to content

Commit 78a4488

Browse files
JoaoJandredhslove
authored andcommitted
Update error message when no snapshot strategy is found while creating snapshot (apache#11455)
1 parent 715af6c commit 78a4488

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
@@ -2829,6 +2829,8 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) {
28292829
} catch (CloudRuntimeException cre) {
28302830
logger.error("Take snapshot: {} failed", volume, cre);
28312831
throw cre;
2832+
} catch (UnsupportedOperationException ex) {
2833+
throw ex;
28322834
} catch (Exception e) {
28332835
if (logger.isDebugEnabled()) {
28342836
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
@@ -4044,10 +4044,8 @@ protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) throws S
40444044

40454045
@Override
40464046
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "taking snapshot", async = true)
4047-
public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm,
4048-
Snapshot.LocationType locationType, boolean asyncBackup, Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication)
4049-
4050-
throws ResourceAllocationException {
4047+
public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm, Snapshot.LocationType locationType, boolean asyncBackup,
4048+
Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication) throws ResourceAllocationException {
40514049
final Snapshot snapshot = takeSnapshotInternal(volumeId, policyId, snapshotId, account, quiescevm, locationType, asyncBackup, zoneIds, poolIds, useStorageReplication);
40524050
if (snapshot != null && MapUtils.isNotEmpty(tags)) {
40534051
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
@@ -1645,7 +1645,8 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
16451645
if (snapshotStrategy == null) {
16461646
_snapshotDao.remove(snapshotId);
16471647
logger.debug("No strategy found for creation of snapshot [{}], removing its record from the database.", snapshot);
1648-
throw new CloudRuntimeException(String.format("Can't find snapshot strategy to deal with snapshot:%s", snapshot.getSnapshotVO()));
1648+
throw new UnsupportedOperationException(String.format("Unable to find a snapshot strategy to create snapshot [%s] of volume [%s]. Please check the logs.",
1649+
snapshot.getSnapshotVO(), volume.getUuid()));
16491650
}
16501651

16511652
SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot);
@@ -1699,7 +1700,7 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
16991700
} catch (Exception e) {
17001701
logger.debug("post process snapshot failed", e);
17011702
}
1702-
} catch (CloudRuntimeException cre) {
1703+
} catch (CloudRuntimeException | UnsupportedOperationException cre) {
17031704
if (logger.isDebugEnabled()) {
17041705
logger.debug("Failed to create snapshot - " + cre.getLocalizedMessage());
17051706
}

0 commit comments

Comments
 (0)