Skip to content

Commit c689d4a

Browse files
committed
CE-113 trace logging and rethrow instead of nesting CloudRuntimeException
1 parent d96b3cd commit c689d4a

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ public SnapshotInfo backupSnapshot(SnapshotInfo snapshot) {
282282
try {
283283
SnapshotResult res = future.get();
284284
if (res.isFailed()) {
285+
// TODO add cleanup actions in this case
286+
// TODO think of whether a runtime exception is really what we want]
287+
285288
throw new CloudRuntimeException(res.getResult());
286289
}
287290
SnapshotInfo destSnapshot = res.getSnapshot();

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,14 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) {
19931993
SnapshotInfo snapshot = null;
19941994
try {
19951995
snapshot = snapshotMgr.takeSnapshot(volume);
1996+
} catch (CloudRuntimeException cre) {
1997+
s_logger.error("Take snapshot: " + volume.getId() + " failed", cre);
1998+
// TODO deal with cleaning the mess
1999+
throw cre;
19962000
} catch (Exception e) {
1997-
s_logger.debug("Take snapshot: " + volume.getId() + " failed", e);
2001+
if(s_logger.isDebugEnabled()) {
2002+
s_logger.debug("unknown exception while taking snapshot for volume " + volume.getId() + " was caught", e);
2003+
}
19982004
throw new CloudRuntimeException("Failed to take snapshot", e);
19992005
}
20002006

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,17 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationExc
11141114
} catch (Exception e) {
11151115
s_logger.debug("post process snapshot failed", e);
11161116
}
1117+
} catch (CloudRuntimeException cre) {
1118+
if(s_logger.isDebugEnabled()) {
1119+
s_logger.debug("Failed to create snapshot" + cre.getLocalizedMessage());
1120+
}
1121+
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
1122+
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize()));
1123+
throw cre;
11171124
} catch (Exception e) {
1118-
s_logger.debug("Failed to create snapshot", e);
1125+
if(s_logger.isDebugEnabled()) {
1126+
s_logger.debug("Failed to create snapshot", e);
1127+
}
11191128
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
11201129
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize()));
11211130
throw new CloudRuntimeException("Failed to create snapshot", e);

0 commit comments

Comments
 (0)