This is an automated email from the ASF dual-hosted git repository.

sureshanaparti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new f2d635683bf Update error message when no snapshot strategy is found 
while creating snapshot (#11455)
f2d635683bf is described below

commit f2d635683bf75baf1251c4326a8947572df13ba6
Author: João Jandre <48719461+joaojan...@users.noreply.github.com>
AuthorDate: Mon Aug 18 05:44:20 2025 -0300

    Update error message when no snapshot strategy is found while creating 
snapshot (#11455)
---
 .../org/apache/cloudstack/storage/volume/VolumeServiceImpl.java     | 2 ++
 server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java    | 6 ++----
 .../main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java   | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
 
b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 3a7b7da7768..e2264629952 100644
--- 
a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ 
b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -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);
diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java 
b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
index 56b0ccd6723..5c5a4044909 100644
--- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
@@ -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);
diff --git 
a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java 
b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 818e63bbcc1..f6c8655fd66 100755
--- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -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());
             }

Reply via email to