-
Notifications
You must be signed in to change notification settings - Fork 75
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-67164] Call StepExecution.onResume
in response to WorkflowRun.onLoad
not FlowExecutionList.ItemListenerImpl
#221
Merged
jglick
merged 5 commits into
jenkinsci:master
from
jglick:FlowExecutionList-JENKINS-67164
Jun 3, 2022
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8fba087
[JENKINS-67164] Call `StepExecution.onResume` in response to `Workflo…
jglick b1778a9
Call `StepExecution.onResume` in parallel to the extent possible
jglick a643c5f
Merge branch 'master' of https://github.com/jenkinsci/workflow-api-pl…
jglick 8034dd2
https://github.com/jenkinsci/workflow-api-plugin/pull/221#discussion_…
jglick e10ac66
Typo in comment
jglick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required for correctness or is it an optimization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an optimization. Previously all steps were resumed serially in a topological order. (Or I hope
getCurrentExecutions
enforced a topological order; the sorting byCpsThread
is a bit opaque to me.) The problem in jenkinsci/workflow-durable-task-step-plugin#180 arises when you have a bunch of parallel branches all runningnode
and all of them are going to fail due to missing agents. Previously, Jenkins would wait 5m for the first agent, report that it was gone, then wait 5m for the next agent, etc. Now all thenode
blocks are resumed in parallel, followed by thesh
steps inside them, etc. Have a test demonstrating this inworkflow-durable-task-step
but only now got an incremental build from jenkinsci/workflow-cps-plugin#534 that I needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I guess it's kind of unusual for
ExecutorStepExecution.onResume
to block if no other steps do so, but looking through jenkinsci/workflow-durable-task-step-plugin#180 it seems like you already tried various alternatives, so this seems fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically this is the replacement for the
TryRepeatedly
pickle. I played with a lot of alternatives indeed. I am not claiming this approach is ideal but it seems to be straightforward enough and do the job.Earlier, before hitting on the idea of having
onResume
block, I had hoped to arrange it so that the program would resume right away, and then ash
step running on the dead agent would eventually figure out there was no hope and abort. I ran into problems in functional tests, though, things likeThe program would run past
input
to thesh
step, which would then either fail with aMissingContextVariableException
(confusing) or block the CPS VM thread insideDSL
(which will throw an error if it blocks >5s). Admittedly this is an artificial case (you should not hold an executor like that) but a lot of tests were failing that I had to work around in artificial ways and it seemed uncomfortable. It would have been possible to fix all these cases but only in pretty intrusive ways: by defining a newStepContext
object in lieu ofFilePath
(perhapsDynamicFilePathContext.Representation
) which could be deserialized without pickles, but every step currently expectingFilePath
would need to be adjusted to expect this instead, and then the step would need to have complicated logic to wait for the new contextual object to be ready (translatable to a liveFilePath
) before doing anything useful.The compromise I settled on is closer to the original pickle behavior in that CPS code and steps do not run until an attempt is made to restore the original context: until all open
node
blocks have gotten their agent to reconnect, or timed out trying. The difference is only that in case this fails (with a timeout), the error is thrown out ofStepExecution.onResume
and thusStepContext.onFailure
so it becomes a properly modeledThrowable
with a CPS VM stack trace that we can catch and handle—unlike the original situation where the entire build would be effectively hard-killed with no possible cleanup.