Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define termination milestones for suspending & saving #301

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

jglick
Copy link
Member

@jglick jglick commented Aug 16, 2023

Downstream use in workflow-cps coming soon. Also see jenkinsci/workflow-job-plugin#375.

@jglick jglick merged commit b47f14f into jenkinsci:master Aug 16, 2023
14 checks passed
@jglick jglick deleted the milestones branch August 16, 2023 23:12
jglick added a commit to jglick/workflow-cps-plugin that referenced this pull request Aug 16, 2023
@@ -238,7 +253,9 @@ public void onFailure(@NonNull Throwable t) {
}

@Restricted(DoNotUse.class)
@Terminator public static void saveAll() throws InterruptedException {
@SuppressWarnings("deprecation")
@Terminator(requires = EXECUTIONS_SUSPENDED, attains = LIST_SAVED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I just thought about: if you have workflow-api installed but not workflow-cps, is the reactor smart enough to see that nothing attains EXECUTIONS_SUSPENDED and still allow this to run? Or does it block (bad), or get skipped (fine since you won't have any executions anyway)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the reactor smart enough to see that nothing attains EXECUTIONS_SUSPENDED and still allow this to run?

I wondered the same, but actually you can see from the fact that tests in this plugin pass that it is OK: it just considers EXECUTIONS_SUSPENDED to have attained immediately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually you can see from the fact that tests in this plugin pass that it is OK

Yeah I suspected that was the case, but wanted to make sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not the same scenario as you mention, but similar, since the workflow-cps in test scope of course predates the code that would attain this milestone.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

diff --git src/test/java/org/jenkinsci/plugins/workflow/actions/ErrorActionTest.java src/test/java/org/jenkinsci/plugins/workflow/actions/ErrorActionTest.java
index 53d4dd1..9d99c10 100644
--- src/test/java/org/jenkinsci/plugins/workflow/actions/ErrorActionTest.java
+++ src/test/java/org/jenkinsci/plugins/workflow/actions/ErrorActionTest.java
@@ -79,6 +79,7 @@ public class ErrorActionTest {
     @Test
     public void simpleException() throws Throwable {
         rr.then(r -> {
+            System.setProperty("jenkins.model.Jenkins.termLogLevel", "INFO");
             final String EXPECTED = "For testing purpose";
             WorkflowJob job = r.jenkins.createProject(WorkflowJob.class, "p");
             job.setDefinition(new CpsFlowDefinition(String.format(

INFO	hudson.lifecycle.Lifecycle#onStatusUpdate: Stopping Jenkins
INFO	jenkins.model.Jenkins$16#onAttained: Attained FlowExecutionList.EXECUTIONS_SUSPENDED
INFO	jenkins.model.Jenkins$16#onAttained: Attained Started termination
INFO	jenkins.model.Jenkins$16#onTaskStarted: Started SCMEvent.closeExecutorService
INFO	jenkins.model.Jenkins$16#onTaskCompleted: Completed SCMEvent.closeExecutorService
INFO	jenkins.model.Jenkins$16#onTaskStarted: Started FlowExecutionList.saveAll
INFO	jenkins.model.Jenkins$16#onTaskCompleted: Completed FlowExecutionList.saveAll
INFO	jenkins.model.Jenkins$16#onAttained: Attained FlowExecutionList.LIST_SAVED
INFO	jenkins.model.Jenkins$16#onTaskStarted: Started NioChannelSelector.cleanUp
INFO	jenkins.model.Jenkins$16#onTaskCompleted: Completed NioChannelSelector.cleanUp
INFO	jenkins.model.Jenkins$16#onTaskStarted: Started CpsFlowExecution.suspendAll
INFO	jenkins.model.Jenkins$16#onTaskCompleted: Completed CpsFlowExecution.suspendAll
INFO	jenkins.model.Jenkins$16#onTaskStarted: Started DurableTaskStep.shutDownThreadPool
INFO	jenkins.model.Jenkins$16#onTaskCompleted: Completed DurableTaskStep.shutDownThreadPool
INFO	jenkins.model.Jenkins$16#onTaskStarted: Started IOHubProvider.cleanUp
INFO	jenkins.model.Jenkins$16#onTaskCompleted: Completed IOHubProvider.cleanUp
INFO	jenkins.model.Jenkins$16#onAttained: Attained Completed termination
INFO	hudson.lifecycle.Lifecycle#onStatusUpdate: Jenkins stopped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants