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

[JENKINS-49707] Implement BodyExecution.cancel(Throwable) #570

Merged
merged 5 commits into from
Jul 22, 2022

Conversation

jglick
Copy link
Member

@jglick jglick commented Jul 21, 2022

@jglick
Copy link
Member Author

jglick commented Jul 22, 2022

Cannot reproduce test failure locally; looks like a flake (investigating).

// 'stopped' and 'thread' are updated atomically
CpsThread t;
synchronized (this) {
if (isDone()) return false; // already complete
// TODO should perhaps rather override cancel(Throwable) and make this overload just delegate to that one
stopped = new FlowInterruptedException(Result.ABORTED, causes);
Copy link
Member

Choose a reason for hiding this comment

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

With these changes, any code that currently calls cancel(Throwable) with an exception that is not a FlowInterruptedException will no longer result in a FlowInterruptedException at runtime, so behavior would change. Did you check the PCT? I am not sure how many callers of cancel(Throwable) exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure how many callers of cancel(Throwable) [that do not pass FlowInterruptedException] exist.

I could not find any in common Pipeline plugins. There seem to be a few plugins still improperly overriding stop (not updated like e.g. jenkinsci/workflow-durable-task-step-plugin#49) that I could locate in my local Maven index:

  • DatabaseConnectionStep
  • ExwsExecution
  • GitLabBuildsStep
  • GitLabCommitStatusStep

behavior would change

Indeed it would, though probably for the better—the precise reason for the failure of the body would be thrown up naturally.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, that seems fine. I was just worried that if there was widespread usage then this might cause a bunch of test failures because of things like build results changing from ABORTED to FAILURE.

Copy link
Member Author

@jglick jglick Jul 22, 2022

Choose a reason for hiding this comment

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

Checked usage-in-plugins with -i -M on

org.jenkinsci.plugins.workflow.steps.BodyExecution#cancel

resulting in

    "org/jenkinsci/plugins/workflow/steps/BodyExecution#cancel(Ljava/lang/Throwable;)Z": [
      "applitools-eyes",
      "browserstack-integration",
      "database",
      "external-workspace-manager",
      "gitlab-plugin",
      "performance-signature-dynatrace",
      "performance-signature-dynatracesaas",
      "pipeline-gitstatuswrapper",
      "pipeline-npm",
      "sauce-ondemand",
      "testingbot",
      "workflow-cps",
      "workflow-step-api"
    ]

so looks like the previously mentioned hits plus a few more obscure ones. Checking these quickly, they are all StepExecution.stop overrides. This idiom is deprecated but unlikely to lead to a behavioral change anyway, since if a block-scoped step is running another step in its body, stop will be called on the innermost.

@jglick
Copy link
Member Author

jglick commented Jul 22, 2022

looks like a flake (investigating)

Did not manage to track down the cause of https://github.com/jenkinsci/workflow-cps-plugin/pull/570/checks?check_run_id=7468722365. Seems that the same thread which ran WorkflowRun.finish also somehow triggered CpsFlowExecution.logTimings, which is called only from CpsVmExecutorService.tearDown and thus should only ever be called from the CPS VM thread. No hypothesis there.

testFullyDurableSurvivesDirtyRestart https://github.com/jenkinsci/workflow-cps-plugin/pull/570/checks?check_run_id=7470410029 seems like a flake also. I do not understand this code well enough to analyze what the failure means.

@jglick jglick requested a review from dwnusbaum July 22, 2022 16:26
@jglick jglick marked this pull request as ready for review July 22, 2022 17:00
@jglick jglick enabled auto-merge July 22, 2022 17:01
@jglick jglick merged commit 87459c4 into jenkinsci:master Jul 22, 2022
@jglick jglick deleted the retry-unconditionally-JENKINS-49707 branch July 22, 2022 17:45
jglick added a commit to jglick/workflow-durable-task-step-plugin that referenced this pull request Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants