Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-25894

Ugly reporting of errors from parallel step

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • pipeline
    • None

    Description

      If a step throws an AbortException, the intent is that this is displayed as a single-line error with no stack trace. Yet if this is inside a parallel step, it gets wrapped, twice, and the full stack trace printed to the log:

      Running: End of Workflow
      org.jenkinsci.plugins.workflow.cps.steps.ParallelStepException: Parallel step split3 failed
      	at org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback.checkAllDone(ParallelStep.java:126)
      	at org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback.onFailure(ParallelStep.java:105)
      	at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$FailureAdapter.receive(CpsBodyExecution.java:295)
      	at com.cloudbees.groovy.cps.impl.ThrowBlock$1.receive(ThrowBlock.java:68)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:145)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:262)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:70)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:174)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:172)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:111)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.reflect.UndeclaredThrowableException
      	at org.jenkinsci.plugins.workflow.cps.CpsStepContext.replay(CpsStepContext.java:409)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
      	at WorkflowScript.run(WorkflowScript:15)
      	at Unknown.Unknown(Unknown)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:69)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:100)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:76)
      	at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
      	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
      	at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	... 17 more
      Caused by: hudson.AbortException: None of the test reports contained any result
      	at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:158)
      	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:64)
      	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:55)
      	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:34)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:137)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
      	... 30 more
      Finished: FAILURE
      

      My suggestion: make ParallelStepException extend UndeclaredThrowableException, which ErrorAction unwraps automatically; rewrap a UndeclaredThrowableException thrown by replay (or, better, make whatever calls replay and turns it into an Outcome do this unwrapping); and if the inner exception is an AbortException, throw a wrapping AbortException which just prepends the branch name.

      Attachments

        Issue Links

          Activity

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/72bba7fced5610643be235e7f8cb7d91720ca93e
            Log:
            JENKINS-25894 fix could throw an IllegalArgumentException under some conditions.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep.java http://jenkins-ci.org/commit/workflow-cps-plugin/72bba7fced5610643be235e7f8cb7d91720ca93e Log: JENKINS-25894 fix could throw an IllegalArgumentException under some conditions.

            Code changed in jenkins
            User: Jesse Glick
            Path:
            pom.xml
            src/test/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepRunTest.java
            http://jenkins-ci.org/commit/workflow-basic-steps-plugin/cf118defbbfc7a1581b64cbbc668d6e3b07c337f
            Log:
            JENKINS-25894 Pick up fix from https://github.com/jenkinsci/workflow-cps-plugin/pull/6.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/test/java/org/jenkinsci/plugins/workflow/steps/TimeoutStepRunTest.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/cf118defbbfc7a1581b64cbbc668d6e3b07c337f Log: JENKINS-25894 Pick up fix from https://github.com/jenkinsci/workflow-cps-plugin/pull/6 .

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep.java
            src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepException.java
            src/test/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepTest.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/4fc3310d5e056cc8bee340b91e5c87a989756923
            Log:
            Merge pull request #6 from jglick/ParallelStepException-JENKINS-25894

            JENKINS-25894 Fix reporting of errors from parallel step

            Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/32c5626173ff...4fc3310d5e05

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep.java src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepException.java src/test/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepTest.java http://jenkins-ci.org/commit/workflow-cps-plugin/4fc3310d5e056cc8bee340b91e5c87a989756923 Log: Merge pull request #6 from jglick/ParallelStepException- JENKINS-25894 JENKINS-25894 Fix reporting of errors from parallel step Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/32c5626173ff...4fc3310d5e05

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep.java
            src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepException.java
            src/test/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepTest.java
            http://jenkins-ci.org/commit/workflow-cps-plugin/e0ca68f17d3eeeb52ca0db73ff1bf10e2558bfe6
            Log:
            [FIXED JENKINS-25894] Fix reporting of errors from parallel step.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStep.java src/main/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepException.java src/test/java/org/jenkinsci/plugins/workflow/cps/steps/ParallelStepTest.java http://jenkins-ci.org/commit/workflow-cps-plugin/e0ca68f17d3eeeb52ca0db73ff1bf10e2558bfe6 Log: [FIXED JENKINS-25894] Fix reporting of errors from parallel step.
            jglick Jesse Glick added a comment -

            ErrorAction no longer unwraps anything. replay must have referred to the method in CpsStepContext. InvokerInvocationException now seems to be the relevant exception type.

            jglick Jesse Glick added a comment - ErrorAction no longer unwraps anything. replay must have referred to the method in CpsStepContext . InvokerInvocationException now seems to be the relevant exception type.
            jglick Jesse Glick added a comment -

            JENKINS-26541 dealt with the handling of RejectedAccessException.

            jglick Jesse Glick added a comment - JENKINS-26541 dealt with the handling of RejectedAccessException .
            jglick Jesse Glick added a comment -

            Another problem is that FlowInterruptedException is handled specially, but this is lost when it is wrapped in ParallelStepException, so for example the build in TimeoutStepTest.killingParallel winds up as FAILURE when it ought to have been ABORTED. Thus the several places that check for instanceof FlowInterruptedException (currently CpsThreadGroup.run, CatchErrorStep, and WorkflowRun.finish) needs to look for nested causes.

            jglick Jesse Glick added a comment - Another problem is that FlowInterruptedException is handled specially, but this is lost when it is wrapped in ParallelStepException , so for example the build in TimeoutStepTest.killingParallel winds up as FAILURE when it ought to have been ABORTED . Thus the several places that check for instanceof FlowInterruptedException (currently CpsThreadGroup.run , CatchErrorStep , and WorkflowRun.finish ) needs to look for nested causes.

            People

              Unassigned Unassigned
              jglick Jesse Glick
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: