Skip to content

Commit

Permalink
core: LiveMerge: move getVolumeInfo to executeCommand
Browse files Browse the repository at this point in the history
Call to GetVolumeInfo was added to RemoveSnapshotSingleDiskLive
command before performing the steps, in order to check if the
Destination image (or the Top Image) exists on storage. It was added
to the procedure, which is determining the initial merge step during
the first run of performNextOperation.

GetVolumeInfo is a synchronous call, and calling it from
performNextOperation can block the callback thread which may block
other commands from making progress. This change moves the procedure
of setting the initial merge step back to executeCommand(), like it
is in ColdMergeSnapshotSingleDisk command
  • Loading branch information
mkemel authored and ahadas committed Aug 16, 2022
1 parent 0f8dc6e commit fb7f1eb
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ protected void executeCommand() {
// Let doPolling() drive the execution; we don't have any guarantee that
// executeCommand() will finish before doPolling() is called, and we don't
// want to possibly run the first command twice.
getParameters().setCommandStep(getInitialMergeStepForImage(getParameters().getImageId()));
getParameters().setChildCommands(new HashMap<>());
setSucceeded(true); // Allow runAction to succeed
}

Expand All @@ -83,17 +85,12 @@ public boolean ignoreChildCommandFailure() {

@Override
public boolean performNextOperation(int completedChildCount) {

// Steps are executed such that:
// a) all logic before the command runs is idempotent
// b) the command is the last action in the step
// This allows for recovery after a crash at any point during command execution.

log.debug("Proceeding with execution of RemoveSnapshotSingleDiskLiveCommand");
if (getParameters().getCommandStep() == null) {
getParameters().setCommandStep(getInitialMergeStepForImage(getParameters().getImageId()));
getParameters().setChildCommands(new HashMap<>());
}

// Upon recovery or after invoking a new child command, our map may be missing an entry
syncChildCommandList(getParameters());
Expand Down

0 comments on commit fb7f1eb

Please sign in to comment.