CE-113 trace logging and rethrow instead of nesting CloudRuntimeException

This commit is contained in:
Daan Hoogland 2017-03-30 16:35:37 +02:00
parent d96b3cd19c
commit c689d4a696
3 changed files with 20 additions and 2 deletions

View File

@ -282,6 +282,9 @@ public class SnapshotServiceImpl implements SnapshotService {
try {
SnapshotResult res = future.get();
if (res.isFailed()) {
// TODO add cleanup actions in this case
// TODO think of whether a runtime exception is really what we want]
throw new CloudRuntimeException(res.getResult());
}
SnapshotInfo destSnapshot = res.getSnapshot();

View File

@ -1993,8 +1993,14 @@ public class VolumeServiceImpl implements VolumeService {
SnapshotInfo snapshot = null;
try {
snapshot = snapshotMgr.takeSnapshot(volume);
} catch (CloudRuntimeException cre) {
s_logger.error("Take snapshot: " + volume.getId() + " failed", cre);
// TODO deal with cleaning the mess
throw cre;
} catch (Exception e) {
s_logger.debug("Take snapshot: " + volume.getId() + " failed", e);
if(s_logger.isDebugEnabled()) {
s_logger.debug("unknown exception while taking snapshot for volume " + volume.getId() + " was caught", e);
}
throw new CloudRuntimeException("Failed to take snapshot", e);
}

View File

@ -1114,8 +1114,17 @@ public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implement
} catch (Exception e) {
s_logger.debug("post process snapshot failed", e);
}
} catch (CloudRuntimeException cre) {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Failed to create snapshot" + cre.getLocalizedMessage());
}
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize()));
throw cre;
} catch (Exception e) {
s_logger.debug("Failed to create snapshot", e);
if(s_logger.isDebugEnabled()) {
s_logger.debug("Failed to create snapshot", e);
}
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.snapshot);
_resourceLimitMgr.decrementResourceCount(snapshotOwner.getId(), ResourceType.secondary_storage, new Long(volume.getSize()));
throw new CloudRuntimeException("Failed to create snapshot", e);