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

Flowscanner reimplement jenkins28119 error info #3

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

svanoort
Copy link
Member

@svanoort svanoort commented Apr 27, 2016

Modifies #2 to use the new flow scanners, supplying predicates.

Depends on jenkinsci/workflow-api-plugin#2

@jglick This is the first of the implementations with the new FlowScanners. Would be happy to resubmit as a PR against your fork if you prefer.

return (a != null && stackTraces.contains(Functions.printThrowable(a.getError())));
}
};
return new FlowScanner.DepthFirstScanner().findFirstMatch(getExecution(), threwException);
Copy link
Member Author

@svanoort svanoort Apr 27, 2016

Choose a reason for hiding this comment

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

Once the ForkScanner is complete, it should be far more efficient for this case, because:

  1. It doesn't have to keep a HashSet of all visited FlowNodes (just a stack with depth related to the number of levels of parallel branches).
  2. DepthFirstScanner will walk to the start of the flow, if the failure occurs in any branch branch of a parallel block beyond the first. ForkScanner will only walk the up to the start of the parallel block containing the failure (and then go through the branches there).

Technically the completely optimal case here is probably to jump over blocks without an ErrorAction (if we can guarantee they're attached to all the BlockEndNodes where failures happen) AND to do a proper breadth-first search.

Copy link
Member

Choose a reason for hiding this comment

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

DepthFirstScanner is a top-level type in the current upstream PR.

For a PR downstream of an evolving API PR, it is best to use timestamped snapshots in the Maven dependency, rather than 2.1-SNAPSHOT which is vague.

Copy link
Member

Choose a reason for hiding this comment

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

Performance is not a significant concern for this PR, because this is code run just once per step execution, typically once per build, and from the CPS VM thread. Obviously if you have some system for indexing nodes using specific action classes, that would be helpful as you could go straight to those with ErrorAction.

I did not follow the discussion about ForkScanner here. At any rate, for purposes of this PR we are looking for any FlowNode in the build with an ErrorAction, so long as it is not a BlockEndNode. Possibly we really want to check also BlockEndNodes, to handle errors thrown only during cleanup from build wrappers and the like, but give them a lower priority. The issue is that ErrorAction gets attached to end nodes of blocks which are exited by an uncaught exception, so we want to find the “first” node with the matching action: i.e., giving preference to the nested node. So it would also suffice to do a walk forward in time, rather than backward as I presume DepthFirstScanner does. Seems there is no such scanner yet?

for (Throwable t = error; t != null; t = t.getCause()) {
stackTraces.add(Functions.printThrowable(t));
}
Predicate<FlowNode> threwException = new Predicate<FlowNode>() {
Copy link
Member

Choose a reason for hiding this comment

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

I would inline this variable. Just make sure it is safe for lambda conversion when we switch to -source 8. Most likely this is satisfied by just verifying that there are no method overloads which vary only in the declared type of the SAM they accept. (This is where we screwed up with ACL.impersonate.)

@jglick jglick marked this pull request as draft January 6, 2022 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants