From fa589ffdd5cff10381604c4cb1f45e370d237225 Mon Sep 17 00:00:00 2001 From: Lucas Koehler Date: Thu, 31 Aug 2023 17:35:36 +0200 Subject: [PATCH] #221: Continue cancelled handling for Workspaces The Workspace handling already makes sure steps are not executed twice. Thus, we can simply try handling again Contributed on behalf of STMicroelectronics --- .../handler/impl/LazyWorkspaceHandler.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/LazyWorkspaceHandler.java b/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/LazyWorkspaceHandler.java index f4a6cb7d..8e34181d 100644 --- a/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/LazyWorkspaceHandler.java +++ b/java/operator/org.eclipse.theia.cloud.operator/src/main/java/org/eclipse/theia/cloud/operator/handler/impl/LazyWorkspaceHandler.java @@ -69,27 +69,25 @@ protected boolean doWorkspaceAdded(Workspace workspace, String correlationId) { "Workspace was successfully handled before and is skipped now. Workspace: " + workspace)); return true; } - if (OperatorStatus.HANDLING.equals(operatorStatus)) { - // TODO We should not return but continue where we left off. - LOGGER.warn(formatLogMessage(correlationId, - "Workspace handling was unexpectedly interrupted before. Workspace is skipped now and its status is set to ERROR. Workspace: " - + workspace)); - client.workspaces().updateStatus(correlationId, workspace, s -> { - s.setOperatorStatus(OperatorStatus.ERROR); - s.setOperatorMessage("Handling was unexpectedly interrupted before. CorrelationId: " + correlationId); - }); - return false; - } if (OperatorStatus.ERROR.equals(operatorStatus)) { LOGGER.warn(formatLogMessage(correlationId, "Workspace could not be handled before and is skipped now. Workspace: " + workspace)); return false; } - - // Set workspace status to being handled - client.workspaces().updateStatus(correlationId, workspace, s -> { - s.setOperatorStatus(OperatorStatus.HANDLING); - }); + if (OperatorStatus.HANDLING.equals(operatorStatus)) { + LOGGER.debug(formatLogMessage(correlationId, + "Workspace handling was unexpectedly interrupted before and is continued now. Workspace: " + + workspace)); + client.workspaces().updateStatus(correlationId, workspace, s -> { + // Reset status message + s.setOperatorMessage(""); + }); + } else { + // Set workspace status to being handled + client.workspaces().updateStatus(correlationId, workspace, s -> { + s.setOperatorStatus(OperatorStatus.HANDLING); + }); + } String storageName = WorkspaceUtil.getStorageName(workspace); client.workspaces().updateStatus(correlationId, workspace, s -> s.setVolumeClaim(new StatusStep("started")));