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

pipeline timeout doesn't kill the job

    XMLWordPrintable

Details

    Description

      On this pipeline

      node {
          
          timeout(time: 30, unit: 'SECONDS') {
              environment = 'staging'
              stage 'Retrieving repositories'
              parallel getDBUri: {
                  // Obtain pipeline and DB_URI using a script in the pipeline
                  dir('pipelineRepo') {
                      git ...
                      pipeline = load 'pipeline.groovy'
                      sh 'pwd'
                      withCredentials([
                          [
                              $class: 'StringBinding', 
                              credentialsId: 'herokuToken', 
                              variable: 'token'
                          ]
                      ]) {
                          env.PG_URI = pipeline.herokuVariable( 'novus-'+environment, 'DB_URI', env.token )
                      }
                  }
              }, getScript: {
                  // Obtain script to execute and install dependencies
                  dir('scriptRepo') {
                      git ..
                      withCredentials([
                          [
                              $class: 'StringBinding', 
                              credentialsId: 'NpmToken', 
                              variable: 'NPM_TOKEN'
                          ]
                      ]) {
                          sh 'echo "//registry.npmjs.org/:_authToken='+env.NPM_TOKEN+'" > ~/.npmrc'
                          sh 'npm install --production && npm prune --production'
                          sh 'unlink ~/.npmrc'
                      }
                  }
              },
              failFast: true
          }
      

      The timeout is honoured but not executed correctly

      [Pipeline] [getDBUri] }
      Cancelling nested steps due to timeout
      [getScript] Sending interrupt signal to process
      [getScript] Sending interrupt signal to process
      Body did not finish within grace period; terminating with extreme prejudice
      [Pipeline] // parallel
      [Pipeline] }
      [Pipeline] [getScript] }
      [Pipeline] // timeout
      [Pipeline] }
      [Pipeline] // node
      Aborted by admin
      [Pipeline] [getScript] }
      Click here to forcibly terminate running steps
      Terminating withCredentials
      Click here to forcibly kill entire build
      Hard kill!
      Finished: ABORTED
      

      Neither the manual aborting worked at the beginning I had to use "Click here to forcibly kill entire build", the timeout option should have an option to kill the build in the worst case

      Attachments

        Issue Links

          Activity

            diversario ilya s added a comment -

            According to this example that's not accurate, since in the output we still get the second echo from within the timeout block.

            diversario ilya s added a comment - According to this example that's not accurate , since in the output we still get the second echo from within the timeout block.
            amirbarkal Amir Barkal added a comment - - edited

            Another simple reproduction of the timeout() step not throwing an exception:

            node() {
              try {
               timeout(time: 3 as Integer, unit: 'SECONDS') {
                 int result = sh(returnStatus: true, script:'sleep 5')
               }
              }
              catch(e) {
                println "TIMEOUT" // Will never get here
                throw e
              }
            }
            

             

             

            Env details:

            Jenkins 2.138

            workflow-basic-steps 2.9

             

            amirbarkal Amir Barkal added a comment - - edited Another simple reproduction of the timeout() step not throwing an exception: node() { try { timeout(time: 3 as Integer , unit: 'SECONDS' ) { int result = sh(returnStatus: true , script: 'sleep 5' ) } } catch (e) { println "TIMEOUT" // Will never get here throw e } }     Env details: Jenkins  2.138 workflow-basic-steps 2.9  
            jglick Jesse Glick added a comment -

            amirbarkal that case is perhaps a duplicate of JENKINS-28822.

            jglick Jesse Glick added a comment - amirbarkal that case is perhaps a duplicate of JENKINS-28822 .
            jgray599 Jonathan Gray added a comment -

            Looks like this is still going on:

            Jenkins 2.164.1

            Pipeline: Basic Steps 2.15

            jgray599 Jonathan Gray added a comment - Looks like this is still going on: Jenkins 2.164.1 Pipeline: Basic Steps 2.15
            jglick Jesse Glick added a comment -

            zwelz3’s case sounds like a bug in durable-task. Hard to say without knowing how to reproduce from scratch.

            maxfields2000’s case is a duplicate of a well-known open bug about cancelling quiet mode.

            diversario’s case is as designed (JENKINS-51928). Ditto plytro.

            Some other cases are old and likely correspond to behavioral fixes in either timeout or specific nested steps done in the past.

            I am closing this issue as it is mixing up a lot of distinct cases and is pretty old. Please do not reopen or add comments. If you have what you consider a bug (after reading JENKINS-51928) which is reproducible using the latest released versions of all plugins and a current Jenkins LTS, please file a separate (but linked) bug report with complete, minimal, self-contained steps to reproduce the problem from scratch.

            jglick Jesse Glick added a comment - zwelz3 ’s case sounds like a bug in durable-task . Hard to say without knowing how to reproduce from scratch. maxfields2000 ’s case is a duplicate of a well-known open bug about cancelling quiet mode. diversario ’s case is as designed ( JENKINS-51928 ). Ditto plytro . Some other cases are old and likely correspond to behavioral fixes in either timeout or specific nested steps done in the past. I am closing this issue as it is mixing up a lot of distinct cases and is pretty old. Please do not reopen or add comments. If you have what you consider a bug (after reading JENKINS-51928 ) which is reproducible using the latest released versions of all plugins and a current Jenkins LTS, please file a separate (but linked) bug report with complete, minimal, self-contained steps to reproduce the problem from scratch.

            People

              Unassigned Unassigned
              maury91 Maurizio Carboni
              Votes:
              24 Vote for this issue
              Watchers:
              31 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: