Update error message when no snapshot strategy is found while creating snapshot (#11455)

This commit is contained in:
João Jandre 2025-08-18 05:44:20 -03:00 committed by GitHub
parent 5a90da3276
commit f2d635683b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

View File

@ -2795,6 +2795,8 @@ public class VolumeServiceImpl implements VolumeService {
} catch (CloudRuntimeException cre) {
logger.error("Take snapshot: {} failed", volume, cre);
throw cre;
} catch (UnsupportedOperationException ex) {
throw ex;
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("unknown exception while taking snapshot for volume {} was caught", volume, e);

View File

@ -3814,10 +3814,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
@Override
@ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "taking snapshot", async = true)
public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm,
Snapshot.LocationType locationType, boolean asyncBackup, Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication)
throws ResourceAllocationException {
public Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm, Snapshot.LocationType locationType, boolean asyncBackup,
Map<String, String> tags, List<Long> zoneIds, List<Long> poolIds, Boolean useStorageReplication) throws ResourceAllocationException {
final Snapshot snapshot = takeSnapshotInternal(volumeId, policyId, snapshotId, account, quiescevm, locationType, asyncBackup, zoneIds, poolIds, useStorageReplication);
if (snapshot != null && MapUtils.isNotEmpty(tags)) {
taggedResourceService.createTags(Collections.singletonList(snapshot.getUuid()), ResourceTag.ResourceObjectType.Snapshot, tags, null);

View File

@ -1621,7 +1621,8 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
if (snapshotStrategy == null) {
_snapshotDao.remove(snapshotId);
logger.debug("No strategy found for creation of snapshot [{}], removing its record from the database.", snapshot);
throw new CloudRuntimeException(String.format("Can't find snapshot strategy to deal with snapshot:%s", snapshot.getSnapshotVO()));
throw new UnsupportedOperationException(String.format("Unable to find a snapshot strategy to create snapshot [%s] of volume [%s]. Please check the logs.",
snapshot.getSnapshotVO(), volume.getUuid()));
}
SnapshotInfo snapshotOnPrimary = snapshotStrategy.takeSnapshot(snapshot);
@ -1672,7 +1673,7 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
} catch (Exception e) {
logger.debug("post process snapshot failed", e);
}
} catch (CloudRuntimeException cre) {
} catch (CloudRuntimeException | UnsupportedOperationException cre) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to create snapshot" + cre.getLocalizedMessage());
}