Skip to content

Commit

Permalink
Add fix for Download-Only deployment type on DDI-API (#848)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen Laverman <[email protected]>
  • Loading branch information
Jeroen Laverman authored Jun 12, 2019
1 parent be17958 commit 34fc7a7
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ default boolean isForced() {
return ActionType.FORCED == getActionType();
}

/**
* @return true when action is downloadonly, false otherwise
*/
default boolean isDownloadOnly() {
return ActionType.DOWNLOAD_ONLY == getActionType();
}

/**
* Action status as reported by the controller.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
final DdiActionHistory actionHistory = actionHistoryMsgs.isEmpty() ? null
: new DdiActionHistory(action.getStatus().name(), actionHistoryMsgs);

final HandlingType downloadType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
final HandlingType downloadType = calculateDownloadType(action);
final HandlingType updateType = calculateUpdateType(action, downloadType);

final DdiMaintenanceWindowStatus maintenanceWindow = calculateMaintenanceWindow(action);

final DdiDeploymentBase base = new DdiDeploymentBase(Long.toString(action.getId()),
new DdiDeployment(downloadType, updateType, chunks, maintenanceWindow), actionHistory);

LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", controllerId, base);
LOG.debug("Found an active UpdateAction for target {}. returning deployment: {}", controllerId, base);

controllerManagement.registerRetrieved(action.getId(), RepositoryConstants.SERVER_MESSAGE_PREFIX
+ "Target retrieved update action and should start now the download.");
Expand All @@ -313,6 +313,13 @@ public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
return ResponseEntity.notFound().build();
}

private static HandlingType calculateDownloadType(final Action action) {
if (action.isDownloadOnly() || action.isForce()) {
return HandlingType.FORCED;
}
return HandlingType.ATTEMPT;
}

private static DdiMaintenanceWindowStatus calculateMaintenanceWindow(final Action action) {
if (action.hasMaintenanceSchedule()) {
return action.isMaintenanceWindowAvailable() ? DdiMaintenanceWindowStatus.AVAILABLE
Expand All @@ -322,7 +329,9 @@ private static DdiMaintenanceWindowStatus calculateMaintenanceWindow(final Actio
}

private static HandlingType calculateUpdateType(final Action action, final HandlingType downloadType) {
if (action.hasMaintenanceSchedule()) {
if (action.isDownloadOnly()) {
return HandlingType.SKIP;
} else if (action.hasMaintenanceSchedule()) {
return action.isMaintenanceWindowAvailable() ? downloadType : HandlingType.SKIP;
}
return downloadType;
Expand Down
Loading

0 comments on commit 34fc7a7

Please sign in to comment.