koushik-das commented on a change in pull request #2081: CLOUDSTACK-9894 Separate creation and backup operations for a volume snapshot URL: https://github.com/apache/cloudstack/pull/2081#discussion_r125397193
########## File path: engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java ########## @@ -300,19 +307,22 @@ protected Void copySnapshotAsyncCallback(AsyncCallbackDispatcher<SnapshotService CopyCommandResult result = callback.getResult(); SnapshotInfo destSnapshot = context.destSnapshot; SnapshotObject srcSnapshot = (SnapshotObject)context.srcSnapshot; + Object payload = srcSnapshot.getPayload(); + CreateSnapshotPayload createSnapshotPayload = (CreateSnapshotPayload)payload; AsyncCallFuture<SnapshotResult> future = context.future; SnapshotResult snapResult = new SnapshotResult(destSnapshot, result.getAnswer()); if (result.isFailed()) { try { - destSnapshot.processEvent(Event.OperationFailed); - //if backup snapshot failed, mark srcSnapshot in snapshot_store_ref as failed also - srcSnapshot.processEvent(Event.DestroyRequested); - srcSnapshot.processEvent(Event.OperationSuccessed); - - srcSnapshot.processEvent(Snapshot.Event.OperationFailed); - _snapshotDao.remove(srcSnapshot.getId()); - } catch (NoTransitionException e) { - s_logger.debug("Failed to update state: " + e.toString()); + if (createSnapshotPayload.getAsyncBackup()) { + destSnapshot.processEvent(Event.OperationFailed); + throw new SnapshotBackupException("Failed in creating backup of snapshot with ID "+srcSnapshot.getId()); + } else { + destSnapshot.processEvent(Event.OperationFailed); + //if backup snapshot failed, mark srcSnapshot in snapshot_store_ref as failed also + cleanupOnSnapshotBackupFailure(context.srcSnapshot); + } + } catch (SnapshotBackupException e) { Review comment: Why NoTransitionException handler is removed? What if destSnapshot.processEvent() throws exception? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services