From 3029504a2a2ee99f3a61a51bc7581429f5e78709 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 16 Aug 2023 17:58:19 -0400 Subject: [PATCH 1/3] Honoring termination milestones --- plugin/pom.xml | 6 ++++++ .../plugins/workflow/cps/CpsFlowExecution.java | 9 ++------- .../plugins/workflow/cps/CpsFlowExecutionTest.java | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index a1ab7b669..f181a89c8 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -55,6 +55,12 @@ import pom + + + org.jenkins-ci.plugins.workflow + workflow-api + 999999-SNAPSHOT + diff --git a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java index c993d3c5a..05431d838 100644 --- a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java +++ b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java @@ -1619,7 +1619,8 @@ public void pause(final boolean v) throws IOException { } @Restricted(DoNotUse.class) - @Terminator public static void suspendAll() { + @Terminator(attains = FlowExecutionList.EXECUTIONS_SUSPENDED) + public static void suspendAll() { CpsFlowExecution exec = null; try (Timeout t = Timeout.limit(3, TimeUnit.MINUTES)) { // TODO some complicated sequence of calls to Futures could allow all of them to run in parallel LOGGER.fine("starting to suspend all executions"); @@ -2164,10 +2165,4 @@ private void checkAndAbortNonresumableBuild() { } } - /** Ensures that even if we're limiting persistence of data for performance, we still write out data for shutdown. */ - @Override - protected void notifyShutdown() { - // No-op, handled in the suspendAll terminator - } - } diff --git a/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecutionTest.java b/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecutionTest.java index ca20b6ec8..b82e0cc21 100644 --- a/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecutionTest.java +++ b/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecutionTest.java @@ -58,6 +58,7 @@ import jenkins.model.Jenkins; import org.apache.commons.io.FileUtils; import org.hamcrest.Matchers; +import static org.hamcrest.Matchers.containsInRelativeOrder; import org.htmlunit.ElementNotFoundException; import org.htmlunit.FailingHttpStatusCodeException; import org.htmlunit.HttpMethod; @@ -66,6 +67,7 @@ import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted; import org.jenkinsci.plugins.workflow.cps.GroovySourceFileAllowlist.DefaultAllowlist; import org.jenkinsci.plugins.workflow.flow.FlowExecution; +import org.jenkinsci.plugins.workflow.flow.FlowExecutionList; import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; @@ -622,4 +624,16 @@ public boolean isAllowed(String groovyResourceUrl) { assertThat(EnvActionImpl.forRun(b).getEnvironment().get("foo"), equalTo("bar")); }); } + + @Test public void suspendOrder() throws Throwable { + System.setProperty(Jenkins.class.getName() + "." + "termLogLevel", "INFO"); + logger.record(CpsFlowExecution.class, Level.FINE).record(FlowExecutionList.class, Level.FINE).capture(100); + sessions.then(r -> { + WorkflowJob p = r.createProject(WorkflowJob.class); + p.setDefinition(new CpsFlowDefinition("echo 'ok'", true)); + r.buildAndAssertSuccess(p); + }); + assertThat(logger.getMessages(), containsInRelativeOrder("finished suspending all executions", "ensuring all executions are saved")); + } + } From 5987a7e37d2992ee9f07c4f0c3ef9b7b3f9bb5a8 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 16 Aug 2023 18:13:25 -0400 Subject: [PATCH 2/3] Incremental dep --- plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index f181a89c8..46278efa4 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -59,7 +59,7 @@ org.jenkins-ci.plugins.workflow workflow-api - 999999-SNAPSHOT + 1258.vfc6961b_b_02e1 From 43ae460c9add779f130bfc39615f22170634c551 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 16 Aug 2023 19:29:45 -0400 Subject: [PATCH 3/3] https://github.com/jenkinsci/workflow-api-plugin/pull/301 released --- plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index 46278efa4..4c79749ee 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -59,7 +59,7 @@ org.jenkins-ci.plugins.workflow workflow-api - 1258.vfc6961b_b_02e1 + 1259.vb_47f14fffc8a_