diff --git a/core/src/main/java/dev/vml/es/acm/core/code/ExecutionContext.java b/core/src/main/java/dev/vml/es/acm/core/code/ExecutionContext.java index fa6ec1fe..97a2c33d 100644 --- a/core/src/main/java/dev/vml/es/acm/core/code/ExecutionContext.java +++ b/core/src/main/java/dev/vml/es/acm/core/code/ExecutionContext.java @@ -36,7 +36,7 @@ public static String varPath(String executionId) { private boolean debug = false; - private boolean locking = true; + private boolean skipped = false; private final Inputs inputs; @@ -143,12 +143,12 @@ public void setDebug(boolean debug) { this.debug = debug; } - public boolean isLocking() { - return locking; + public boolean isSkipped() { + return skipped; } - public void setLocking(boolean locking) { - this.locking = locking; + public void setSkipped(boolean skipped) { + this.skipped = skipped; } public Inputs getInputs() { diff --git a/core/src/main/java/dev/vml/es/acm/core/code/ExecutionId.java b/core/src/main/java/dev/vml/es/acm/core/code/ExecutionId.java index 7d89f7f1..9600481b 100644 --- a/core/src/main/java/dev/vml/es/acm/core/code/ExecutionId.java +++ b/core/src/main/java/dev/vml/es/acm/core/code/ExecutionId.java @@ -6,6 +6,8 @@ public final class ExecutionId { + public static final String HEALTH_CHECK = "health-check"; + private ExecutionId() { // intentionally empty } diff --git a/core/src/main/java/dev/vml/es/acm/core/code/Executor.java b/core/src/main/java/dev/vml/es/acm/core/code/Executor.java index 5ee248a9..e818aedb 100644 --- a/core/src/main/java/dev/vml/es/acm/core/code/Executor.java +++ b/core/src/main/java/dev/vml/es/acm/core/code/Executor.java @@ -183,6 +183,11 @@ public Execution execute(ExecutionContext context) throws AcmException { private ContextualExecution executeInternal(ExecutionContext context) { ContextualExecution.Builder execution = new ContextualExecution.Builder(context).start(); + boolean healthChecking = ExecutionId.HEALTH_CHECK.equals(context.getId()); + if ((!healthChecking && context.isSkipped())) { + return execution.end(ExecutionStatus.SKIPPED); + } + try { statuses.put(context.getId(), ExecutionStatus.PARSING); @@ -204,13 +209,14 @@ private ContextualExecution executeInternal(ExecutionContext context) { return execution.end(ExecutionStatus.SUCCEEDED); } + boolean locking = !healthChecking; String lockName = executableLockName(context); - if (context.isLocking() && queryLocker(resolverFactory, l -> l.isLocked(lockName))) { + if (locking && queryLocker(resolverFactory, l -> l.isLocked(lockName))) { return execution.end(ExecutionStatus.SKIPPED); } try { - if (context.isLocking()) { + if (locking) { useLocker(resolverFactory, l -> l.lock(lockName)); } statuses.put(context.getId(), ExecutionStatus.RUNNING); @@ -222,7 +228,7 @@ private ContextualExecution executeInternal(ExecutionContext context) { contentScript.run(); return execution.end(ExecutionStatus.SUCCEEDED); } finally { - if (context.isLocking()) { + if (locking) { useLocker(resolverFactory, l -> l.unlock(lockName)); } } diff --git a/core/src/main/java/dev/vml/es/acm/core/instance/HealthChecker.java b/core/src/main/java/dev/vml/es/acm/core/instance/HealthChecker.java index 140c0003..3446df94 100644 --- a/core/src/main/java/dev/vml/es/acm/core/instance/HealthChecker.java +++ b/core/src/main/java/dev/vml/es/acm/core/instance/HealthChecker.java @@ -243,7 +243,7 @@ private void checkComponents(List issues) { private void checkCodeExecutor(List issues, ResourceResolver resourceResolver) { try (ExecutionContext context = executor.createContext( - ExecutionId.generate(), + ExecutionId.HEALTH_CHECK, resourceResolver.getUserID(), ExecutionMode.RUN, Code.consoleMinimal(), @@ -251,7 +251,6 @@ private void checkCodeExecutor(List issues, ResourceResolver resour resourceResolver, new CodeOutputMemory())) { context.setHistory(false); - context.setLocking(false); Execution execution = executor.execute(context); if (execution.getStatus() != ExecutionStatus.SUCCEEDED) {