[JIRA] (JENKINS-61959) CpsThread(Timeout) raises InterruptedException

20 views
Skip to first unread message

thomas.ullrich@gmx.net (JIRA)

unread,
Apr 18, 2020, 6:26:03 AM4/18/20
to jenkinsc...@googlegroups.com
Thomas Ullrich created an issue
 
Jenkins / Bug JENKINS-61959
CpsThread(Timeout) raises InterruptedException
Issue Type: Bug Bug
Assignee: Unassigned
Components: workflow-cps-plugin
Created: 2020-04-18 10:25
Environment: Jenkins ver. 2.190.1
workflow CPS plugin ver. 2.80
Priority: Major Major
Reporter: Thomas Ullrich
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

thomas.ullrich@gmx.net (JIRA)

unread,
Apr 18, 2020, 6:31:03 AM4/18/20
to jenkinsc...@googlegroups.com
Thomas Ullrich updated an issue
Change By: Thomas Ullrich
Our declarative pipeline(for isolating the problem) is using a custom step of our shared library. This custom step shall represent a long running REST call by just calling Thread.sleep (360000).

Code:

 

{{pipeline
\{
    agent
    {
        label'master'
    }
    options
    \{
        timestamps()
        buildDiscarder(logRotator(numToKeepStr: '10'))
        skipDefaultCheckout()
    }

    stages
    \{
        stage('Thread.sleep')
        {

            steps{
                sleepService(360000)
            }
        }
    }
}}}

Custom step from shared library:

 

{{import java.lang.*;

def String call(long millis) \{

    timeout(600)
    {
        echo "Current thread name: ${Thread.currentThread().getName()}"
        echo "Current thread classname: ${Thread.currentThread().getClass().getName()}"
        Thread.sleep (millis)
    }
}}}

Executing this, is causing the following exception:

 

{{java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Native Method)
    at java_lang_Thread$sleep.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
    at soiServiceSleep.call(soiServiceSleep.groovy:9)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
    at sun.reflect.GeneratedMethodAccessor577.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
    at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
    at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
    at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
    at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
    at com.cloudbees.groovy.cps.Next.step(Next.java:83)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:405)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:317)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:281)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)}}

It seems like this is caused by timeout of 5 minutes of the CPSThread. Is this a bug in the CPS thread or is there a way to extend the custom steps to avoid this problem?

thomas.ullrich@gmx.net (JIRA)

unread,
May 1, 2020, 12:42:03 PM5/1/20
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
May 1, 2020, 12:54:05 PM5/1/20
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Unassigned
Change By: Jesse Glick
Assignee: Jesse Glick

jglick@cloudbees.com (JIRA)

unread,
May 1, 2020, 12:56:02 PM5/1/20
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Not A Defect
 

A library is not a “custom step”, that would be implemented in Java (and there is one for HTTP calls already). You may not block the CPS VM thread. All operations must be asynchronous.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Not A Defect

thomas.ullrich@gmx.net (JIRA)

unread,
May 2, 2020, 5:44:02 PM5/2/20
to jenkinsc...@googlegroups.com
Thomas Ullrich commented on Bug JENKINS-61959
 
Re: CpsThread(Timeout) raises InterruptedException

Can you tell me any examples for these asynchronous operations?

jglick@cloudbees.com (JIRA)

unread,
May 4, 2020, 8:07:03 AM5/4/20
to jenkinsc...@googlegroups.com

thomas.ullrich@gmx.net (JIRA)

unread,
May 5, 2020, 12:42:02 AM5/5/20
to jenkinsc...@googlegroups.com
Thomas Ullrich commented on Bug JENKINS-61959
 
Re: CpsThread(Timeout) raises InterruptedException

Thanks for the link. I tried it out and it worked. Great!

Reply all
Reply to author
Forward
0 new messages