Skip to content

Commit

Permalink
#200: Remove app definition error handling temporarily
Browse files Browse the repository at this point in the history
There are some issues with setting app definitions status that need to be fixed first
  • Loading branch information
lucas-koehler committed Aug 1, 2023
1 parent 3ad91d1 commit 5184621
Showing 1 changed file with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@

import static org.eclipse.theia.cloud.common.util.LogMessageUtil.formatLogMessage;

import java.util.Optional;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.theia.cloud.common.k8s.client.TheiaCloudClient;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinition;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionSpec;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionStatus;
import org.eclipse.theia.cloud.common.k8s.resource.OperatorStatus;
import org.eclipse.theia.cloud.common.k8s.resource.ResourceStatus;
import org.eclipse.theia.cloud.operator.handler.AppDefinitionHandler;
import org.eclipse.theia.cloud.operator.handler.IngressPathProvider;
import org.eclipse.theia.cloud.operator.handler.util.TheiaCloudIngressUtil;
Expand All @@ -48,20 +43,20 @@ public class LazyStartAppDefinitionHandler implements AppDefinitionHandler {
public boolean appDefinitionAdded(AppDefinition appDefinition, String correlationId) {
LOGGER.info(formatLogMessage(correlationId, "Handling " + appDefinition));

// Check current session status and ignore if handling failed before
Optional<AppDefinitionStatus> status = Optional.ofNullable(appDefinition.getStatus());
String operatorStatus = status.map(ResourceStatus::getOperatorStatus).orElse(OperatorStatus.NEW);
if (OperatorStatus.ERROR.equals(operatorStatus) || OperatorStatus.HANDLING.equals(operatorStatus)) {
LOGGER.warn(formatLogMessage(correlationId,
"AppDefinition could not be handled before and is skipped now. Current status: " + operatorStatus
+ ". AppDefinition: " + appDefinition));
return false;
}
// TODO Check current session status and ignore if handling failed before
// Optional<AppDefinitionStatus> status = Optional.ofNullable(appDefinition.getStatus());
// String operatorStatus = status.map(ResourceStatus::getOperatorStatus).orElse(OperatorStatus.NEW);
// if (OperatorStatus.ERROR.equals(operatorStatus) || OperatorStatus.HANDLING.equals(operatorStatus)) {
// LOGGER.warn(formatLogMessage(correlationId,
// "AppDefinition could not be handled before and is skipped now. Current status: " + operatorStatus
// + ". AppDefinition: " + appDefinition));
// return false;
// }

// Set app definition status to being handled
client.appDefinitions().updateStatus(correlationId, appDefinition, s -> {
s.setOperatorStatus(OperatorStatus.HANDLING);
});
// TODO Set app definition status to being handled
// client.appDefinitions().updateStatus(correlationId, appDefinition, s -> {
// s.setOperatorStatus(OperatorStatus.HANDLING);
// });

AppDefinitionSpec spec = appDefinition.getSpec();
String appDefinitionResourceName = appDefinition.getMetadata().getName();
Expand All @@ -72,18 +67,20 @@ public boolean appDefinitionAdded(AppDefinition appDefinition, String correlatio
LOGGER.error(formatLogMessage(correlationId,
"Expected ingress '" + spec.getIngressname() + "' for app definition '" + appDefinitionResourceName
+ "' does not exist. Abort handling app definition."));
client.appDefinitions().updateStatus(correlationId, appDefinition, s -> {
s.setOperatorStatus(OperatorStatus.ERROR);
s.setOperatorMessage("Ingress does not exist.");
});
// TODO update status
// client.appDefinitions().updateStatus(correlationId, appDefinition, s -> {
// s.setOperatorStatus(OperatorStatus.ERROR);
// s.setOperatorMessage("Ingress does not exist.");
// });
return false;
} else {
LOGGER.trace(formatLogMessage(correlationId, "Ingress available already"));
}

client.appDefinitions().updateStatus(correlationId, appDefinition, s -> {
s.setOperatorStatus(OperatorStatus.HANDLED);
});
// TODO update status
// client.appDefinitions().updateStatus(correlationId, appDefinition, s -> {
// s.setOperatorStatus(OperatorStatus.HANDLED);
// });
return true;
}

Expand Down

0 comments on commit 5184621

Please sign in to comment.