Jenkins pipeline docker.image调用生成超时

epfja78i  于 2023-05-28  发布在  Jenkins
关注(0)|答案(4)|浏览(148)

我最近升级了我的jenkins/Docker安装,因为,当我在我的jenkins管道脚本中运行docker时,我会随机遇到超时,其中我启动了一个docker如下:

docker.image("${dockerImage}").inside(' -v /opt/software/:/software/:Z'){
 .....
}

这是随机发生的,我的作业崩溃并显示以下错误消息(请参阅此线程底部的扩展日志):

ERROR: Timeout after 10 seconds

**UPDATE:**我的管道脚本:

stage('Build'){
    node("master"){
    withEnv(['GIT_SSL_NO_VERIFY=true']){ 
            checkout([$class: 'GitSCM', branches: [[name: "$myGitSHA"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId:"${myGitCredentialsId}" , url:"${myGitUrl}" ]]])
        }

        docker.image("${dockerImage}").inside(' -v /opt/software/:/software/:Z'){
            // Cleaning any the previous build
            sh "make all"
        } // docker               
    } // node
} // stage

我想知道是否有一个选项可以将当前设置的默认超时值增加到10 s。
谢谢

$ docker run -t -d -u 995:993 -v /opt/software/:/software/:Z -w /var/lib/jenkins/jobs/RegressionTests/jobs/rg_centos5-x86_64-gcc-4.1.2/workspace 
-v /var/lib/jenkins/jobs/RegressionTests/jobs/rg_centos5-x86_64-gcc-4.1.2/workspace:/var/lib/jenkins/jobs/RegressionTests/jobs/rg_centos5-x86_64-gcc-4.1.2/workspace:rw 
-v /var/lib/jenkins/jobs/RegressionTests/jobs/rg_centos5-x86_64-gcc-4.1.2/workspace@tmp:/var/lib/jenkins/jobs/RegressionTests/jobs/rg_centos5-x86_64-gcc-4.1.2/workspace@tmp:rw 
-e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** 
-e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat centos5_labs_ompi14
ERROR: Timeout after 10 seconds

java.io.IOException: Failed to run image 'centos5_labs_ompi14'. Error: 
    at org.jenkinsci.plugins.docker.workflow.client.DockerClient.run(DockerClient.java:127)
    at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:178)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:184)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
    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:18)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(jar:file:/var/lib/jenkins/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:128)
    at org.jenkinsci.plugins.docker.workflow.Docker.node(jar:file:/var/lib/jenkins/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:63)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(jar:file:/var/lib/jenkins/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:116)
    at Script1.extMain(Script1.groovy:305)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
    at sun.reflect.GeneratedMethodAccessor349.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.ClosureBlock.eval(ClosureBlock.java:46)
    at com.cloudbees.groovy.cps.Next.step(Next.java:74)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:165)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    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:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
z9ju0rcb

z9ju0rcb1#

该问题是由于硬编码的10 s超时值,因为可以从该链接读取它; docker工作流插件https:github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L268
在某些情况下,这太短了。一种解决方案是将该超时值作为由用户设置的参数。

r3i60tvu

r3i60tvu2#

从昨天开始我也遇到了同样的问题。Docker pipeline版本是1.10。
当它试图从下面的文件启动docker容器时,就会发生问题。

def abcd_image = docker.image('172.16.181.203:5000/abcd:1.0.0.7')
        abcd_image.inside("--privileged -u root -v ${actual_workspace}:${chroot}/code") {

我尝试ssh进入docker主机并重新启动docker服务。之后,它工作,但问题回来后,几个小时。

8ljdwjyq

8ljdwjyq3#

您可以使用“timeout”选项手动设置超时限制。
为Pipeline运行设置一个超时时间,在此之后Jenkins应该中止Pipeline。例如:
options { timeout(time: 1, unit: 'HOURS') }
https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-timeout-code-enforce-time-limit

mlmc2os5

mlmc2os54#

我最近在一次随机运行中看到了这个错误。
我使用的是Jenkins版本2.375.2和Docker插件1.2.10
我建议升级到较新的版本(目前为1.3.2)。

相关问题