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

pipeline timeout doesn't kill the job

    XMLWordPrintable

    Details

    • Similar Issues:

      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

            Hide
            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.

            Show
            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.
            Hide
            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

             

            Show
            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  
            Hide
            jglick Jesse Glick added a comment -

            Amir Barkal that case is perhaps a duplicate of JENKINS-28822.

            Show
            jglick Jesse Glick added a comment - Amir Barkal that case is perhaps a duplicate of JENKINS-28822 .
            Hide
            jgray599 Jonathan Gray added a comment -

            Looks like this is still going on:

            Jenkins 2.164.1

            Pipeline: Basic Steps 2.15

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

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

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

            ilya s’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.

            Show
            jglick Jesse Glick added a comment - Zach Welz ’s case sounds like a bug in durable-task . Hard to say without knowing how to reproduce from scratch. Maxfield Stewart ’s case is a duplicate of a well-known open bug about cancelling quiet mode. ilya s ’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

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

                Dates

                Created:
                Updated:
                Resolved: