-
-
Notifications
You must be signed in to change notification settings - Fork 126
Flowscanner reimplement jenkins28119 error info #3
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
cf118de
d8cf0e2
81e422d
5b5d33d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
|
|
||
| package org.jenkinsci.plugins.workflow.steps; | ||
|
|
||
| import com.google.common.base.Predicate; | ||
| import com.google.inject.Inject; | ||
| import hudson.AbortException; | ||
| import hudson.Extension; | ||
|
|
@@ -42,9 +43,8 @@ | |
| import org.jenkinsci.plugins.workflow.flow.FlowExecution; | ||
| import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner; | ||
| import org.jenkinsci.plugins.workflow.graph.BlockEndNode; | ||
| import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker; | ||
| import org.jenkinsci.plugins.workflow.graph.FlowNode; | ||
| import org.jenkinsci.plugins.workflow.graph.FlowNodeSerialWalker; | ||
| import org.jenkinsci.plugins.workflow.graph.FlowScanner; | ||
| import org.kohsuke.stapler.DataBoundConstructor; | ||
|
|
||
| /** | ||
|
|
@@ -115,22 +115,21 @@ private FlowExecution getExecution() throws IOException { | |
| * so we compare by stack trace instead. | ||
| */ | ||
| private @CheckForNull FlowNode getNode() throws IOException { | ||
| Set<String> stackTraces = new HashSet<>(); | ||
| final Set<String> stackTraces = new HashSet<>(); | ||
| for (Throwable t = error; t != null; t = t.getCause()) { | ||
| stackTraces.add(Functions.printThrowable(t)); | ||
| } | ||
| for (FlowNode n : new FlowGraphWalker(getExecution())) { | ||
| if (n instanceof BlockEndNode) { | ||
| continue; // look for the thing it is enclosing | ||
| } | ||
| ErrorAction a = n.getAction(ErrorAction.class); | ||
| if (a != null) { | ||
| if (stackTraces.contains(Functions.printThrowable(a.getError()))) { | ||
| return n; | ||
| Predicate<FlowNode> threwException = new Predicate<FlowNode>() { | ||
| @Override | ||
| public boolean apply(FlowNode input) { | ||
| if (input instanceof BlockEndNode) { | ||
| return false; | ||
| } | ||
| ErrorAction a = input.getAction(ErrorAction.class); | ||
| return (a != null && stackTraces.contains(Functions.printThrowable(a.getError()))); | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| return new FlowScanner.DepthFirstScanner().findFirstMatch(getExecution(), threwException); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a PR downstream of an evolving API PR, it is best to use timestamped snapshots in the Maven dependency, rather than
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I did not follow the discussion about |
||
| } | ||
|
|
||
| @Whitelisted | ||
|
|
@@ -172,15 +171,15 @@ private FlowExecution getExecution() throws IOException { | |
| public @CheckForNull String getLogURL() throws IOException { | ||
| FlowNode n = getNode(); | ||
| if (n != null) { | ||
| for (FlowNode n2 : new FlowNodeSerialWalker(n)) { | ||
| LogAction a = n2.getAction(LogAction.class); | ||
| if (a != null) { | ||
| String u = Jenkins.getActiveInstance().getRootUrl(); | ||
| if (u == null) { | ||
| u = "http://jenkins/"; // placeholder | ||
| } | ||
| return u + n2.getUrl() + a.getUrlName(); | ||
| FlowNode logNode = new FlowScanner.LinearBlockHoppingScanner() | ||
| .findFirstMatch(n, | ||
| FlowScanner.MATCH_HAS_LOG); | ||
| if (logNode != null) { | ||
| String u = Jenkins.getActiveInstance().getRootUrl(); | ||
| if (u == null) { | ||
| u = "http://jenkins/"; // placeholder | ||
| } | ||
| return u + logNode.getUrl() + logNode.getAction(LogAction.class).getUrlName(); | ||
| } | ||
| } | ||
| return null; | ||
|
|
||
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.
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 withACL.impersonate.)