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

parallel step with failFast set to false, parallel branch 'foo' kills other parallel branch 'bar' when foo times-out.

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Environment:
    • Similar Issues:

      Description

      When I try to run parallel branches with failFast set to false, parallel branch 'foo' kills other parallel branch 'bar' when foo times-out.
      When I use try/catch in 'foo', exception is not being handled and 'bar' gets killed.
      In both cases 'bar is getting killed'

      Code snippet without try/catch:

      pipeline {
          agent any
          options {
              timestamps()
              timeout(time: 30, unit: 'MINUTES')
          }
          stages {
              stage('Setup'){
                  steps{
                      script{
                          parallel 'foo': {
                              timeout(time: 60, unit: 'SECONDS'){
                                  sh "sleep 90"
                              }
                              echo "Done with foo"
                          },
                          'bar': {
                              sh "sleep 200"
                              echo "Done with bar"
                          },
                          failFast: false
                      }
                  }
              }
          }
      }
      

      Snippet of the console log without try/catch block (you can see that 'bar' is getting killed):

      [Pipeline] node
      Running on Jenkins in /Users/Shared/Jenkins/Home/workspace/dummy
      [Pipeline] {
      [Pipeline] timestamps
      [Pipeline] {
      [Pipeline] timeout
      16:28:05 Timeout set to expire in 30 min
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Setup)
      [Pipeline] script
      [Pipeline] {
      [Pipeline] parallel
      [Pipeline] [foo] { (Branch: foo)
      [Pipeline] [bar] { (Branch: bar)
      [Pipeline] [foo] timeout
      16:28:05 [foo] Timeout set to expire in 1 min 0 sec
      [Pipeline] [foo] {
      [Pipeline] [bar] sh
      16:28:05 [bar] [dummy] Running shell script
      [Pipeline] [foo] sh
      16:28:05 [bar] + sleep 200
      16:28:05 [foo] [dummy] Running shell script
      16:28:05 [foo] + sleep 90
      16:29:05 [foo] Cancelling nested steps due to timeout
      16:29:05 [bar] sh: line 1:  9520 Terminated: 15          JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-920b4cdf/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-920b4cdf/jenkins-log.txt' 2>&1
      16:29:05 [foo] Sending interrupt signal to process
      16:29:05 [foo] sh: line 1:  9526 Terminated: 15          JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-9c5ebea8/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-9c5ebea8/jenkins-log.txt' 2>&1
      [Pipeline] [bar] }
      16:29:14 [bar] Failed in branch bar
      [Pipeline] [foo] }
      [Pipeline] [foo] // timeout
      [Pipeline] [foo] }
      16:29:14 [foo] Failed in branch foo
      [Pipeline] // parallel
      [Pipeline] }
      [Pipeline] // script
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // timeout
      [Pipeline] }
      [Pipeline] // timestamps
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 143
      Finished: FAILURE
      

      Code snippet with try/catch inside 'foo' branch:

      pipeline {
          agent any
          options {
              timestamps()
              timeout(time: 30, unit: 'MINUTES')
          }
          stages {
              stage('Setup'){
                  steps{
                      script{
                          parallel 'foo': {
                              try{
                                  timeout(time: 60, unit: 'SECONDS'){
                                      sh "sleep 90"
                                  }
                                  echo "Done with foo"
                              } catch(err) {
                                  "Caught exception ignore: ${err}"
                              }
                              
                          },
                          'bar': {
                              sh "sleep 200"
                              echo "Done with bar"
                          },
                          failFast: false
                      }
                  }
              }
          }
      }
      

      Snippet of the console log with try/catch block inside 'foo' branch (you can see that 'bar' is getting killed):

      [Pipeline] node
      Running on Jenkins in /Users/Shared/Jenkins/Home/workspace/dummy
      [Pipeline] {
      [Pipeline] timestamps
      [Pipeline] {
      [Pipeline] timeout
      16:32:58 Timeout set to expire in 30 min
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Setup)
      [Pipeline] script
      [Pipeline] {
      [Pipeline] parallel
      [Pipeline] [foo] { (Branch: foo)
      [Pipeline] [bar] { (Branch: bar)
      [Pipeline] [foo] timeout
      16:32:58 [foo] Timeout set to expire in 1 min 0 sec
      [Pipeline] [foo] {
      [Pipeline] [bar] sh
      16:32:58 [bar] [dummy] Running shell script
      [Pipeline] [foo] sh
      16:32:58 [bar] + sleep 200
      16:32:58 [foo] [dummy] Running shell script
      16:32:58 [foo] + sleep 90
      16:33:58 [foo] Cancelling nested steps due to timeout
      16:33:58 [bar] sh: line 1:  9756 Terminated: 15          JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-4d63fae2/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-4d63fae2/jenkins-log.txt' 2>&1
      16:33:58 [foo] Sending interrupt signal to process
      16:33:58 [foo] sh: line 1:  9762 Terminated: 15          JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-76186e5f/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-76186e5f/jenkins-log.txt' 2>&1
      [Pipeline] [bar] }
      16:34:07 [bar] Failed in branch bar
      [Pipeline] [foo] }
      [Pipeline] [foo] // timeout
      [Pipeline] [foo] }
      [Pipeline] // parallel
      [Pipeline] }
      [Pipeline] // script
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // timeout
      [Pipeline] }
      [Pipeline] // timestamps
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 143
      Finished: FAILURE
      

        Attachments

          Activity

          aravinder111 Aravinder Bandi created issue -
          aravinder111 Aravinder Bandi made changes -
          Field Original Value New Value
          Description When I try to run parallel branches with failFast set to false, parallel branch 'foo' kills other parallel branch 'bar' when foo times-out.
          Also exception is not being handled in try/catch in 'foo' branch.

          {code}
          pipeline {
              agent any
              options {
                  timestamps()
                  timeout(time: 30, unit: 'MINUTES')
              }
              stages {
                  stage('Setup'){
                      steps{
                          script{
                              parallel 'foo': {
                                  try{
                                      timeout(time: 60, unit: 'SECONDS'){
                                          sh "sleep 90"
                                      }
                                      echo "Done with foo"
                                  } catch(err) {
                                      "Caught exception ignore: ${err}"
                                  }
                                  
                              },
                              'bar': {
                                  sh "sleep 200"
                                  echo "Done with bar"
                              },
                              failFast: false
                          }
                      }
                  }
              }
          }
          {code}

          here's a snippet of the console log (you can see that 'bar' is getting killed):
          {code}
          [Pipeline] node
          Running on Jenkins in /Users/Shared/Jenkins/Home/workspace/dummy
          [Pipeline] {
          [Pipeline] timestamps
          [Pipeline] {
          [Pipeline] timeout
          16:32:58 Timeout set to expire in 30 min
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Setup)
          [Pipeline] script
          [Pipeline] {
          [Pipeline] parallel
          [Pipeline] [foo] { (Branch: foo)
          [Pipeline] [bar] { (Branch: bar)
          [Pipeline] [foo] timeout
          16:32:58 [foo] Timeout set to expire in 1 min 0 sec
          [Pipeline] [foo] {
          [Pipeline] [bar] sh
          16:32:58 [bar] [dummy] Running shell script
          [Pipeline] [foo] sh
          16:32:58 [bar] + sleep 200
          16:32:58 [foo] [dummy] Running shell script
          16:32:58 [foo] + sleep 90
          16:33:58 [foo] Cancelling nested steps due to timeout
          16:33:58 [bar] sh: line 1: 9756 Terminated: 15 JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-4d63fae2/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-4d63fae2/jenkins-log.txt' 2>&1
          16:33:58 [foo] Sending interrupt signal to process
          16:33:58 [foo] sh: line 1: 9762 Terminated: 15 JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-76186e5f/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-76186e5f/jenkins-log.txt' 2>&1
          [Pipeline] [bar] }
          16:34:07 [bar] Failed in branch bar
          [Pipeline] [foo] }
          [Pipeline] [foo] // timeout
          [Pipeline] [foo] }
          [Pipeline] // parallel
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // timeout
          [Pipeline] }
          [Pipeline] // timestamps
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code 143
          Finished: FAILURE
          {code}
          When I try to run parallel branches with failFast set to false, parallel branch 'foo' kills other parallel branch 'bar' when foo times-out.
          When I use try/catch in 'foo', exception is not being handled and 'bar' gets killed.
          In both cases 'bar is getting killed'

          Code snippet without try/catch:
          {code}
          pipeline {
              agent any
              options {
                  timestamps()
                  timeout(time: 30, unit: 'MINUTES')
              }
              stages {
                  stage('Setup'){
                      steps{
                          script{
                              parallel 'foo': {
                                  timeout(time: 60, unit: 'SECONDS'){
                                      sh "sleep 90"
                                  }
                                  echo "Done with foo"
                              },
                              'bar': {
                                  sh "sleep 200"
                                  echo "Done with bar"
                              },
                              failFast: false
                          }
                      }
                  }
              }
          }
          {code}

          Snippet of the console log without try/catch block (you can see that 'bar' is getting killed):
          {code}
          [Pipeline] node
          Running on Jenkins in /Users/Shared/Jenkins/Home/workspace/dummy
          [Pipeline] {
          [Pipeline] timestamps
          [Pipeline] {
          [Pipeline] timeout
          16:28:05 Timeout set to expire in 30 min
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Setup)
          [Pipeline] script
          [Pipeline] {
          [Pipeline] parallel
          [Pipeline] [foo] { (Branch: foo)
          [Pipeline] [bar] { (Branch: bar)
          [Pipeline] [foo] timeout
          16:28:05 [foo] Timeout set to expire in 1 min 0 sec
          [Pipeline] [foo] {
          [Pipeline] [bar] sh
          16:28:05 [bar] [dummy] Running shell script
          [Pipeline] [foo] sh
          16:28:05 [bar] + sleep 200
          16:28:05 [foo] [dummy] Running shell script
          16:28:05 [foo] + sleep 90
          16:29:05 [foo] Cancelling nested steps due to timeout
          16:29:05 [bar] sh: line 1: 9520 Terminated: 15 JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-920b4cdf/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-920b4cdf/jenkins-log.txt' 2>&1
          16:29:05 [foo] Sending interrupt signal to process
          16:29:05 [foo] sh: line 1: 9526 Terminated: 15 JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-9c5ebea8/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-9c5ebea8/jenkins-log.txt' 2>&1
          [Pipeline] [bar] }
          16:29:14 [bar] Failed in branch bar
          [Pipeline] [foo] }
          [Pipeline] [foo] // timeout
          [Pipeline] [foo] }
          16:29:14 [foo] Failed in branch foo
          [Pipeline] // parallel
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // timeout
          [Pipeline] }
          [Pipeline] // timestamps
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code 143
          Finished: FAILURE
          {code}

          Code snippet with try/catch inside 'foo' branch:
          {code}
          pipeline {
              agent any
              options {
                  timestamps()
                  timeout(time: 30, unit: 'MINUTES')
              }
              stages {
                  stage('Setup'){
                      steps{
                          script{
                              parallel 'foo': {
                                  try{
                                      timeout(time: 60, unit: 'SECONDS'){
                                          sh "sleep 90"
                                      }
                                      echo "Done with foo"
                                  } catch(err) {
                                      "Caught exception ignore: ${err}"
                                  }
                                  
                              },
                              'bar': {
                                  sh "sleep 200"
                                  echo "Done with bar"
                              },
                              failFast: false
                          }
                      }
                  }
              }
          }
          {code}

          Snippet of the console log with try/catch block inside 'foo' branch (you can see that 'bar' is getting killed):
          {code}
          [Pipeline] node
          Running on Jenkins in /Users/Shared/Jenkins/Home/workspace/dummy
          [Pipeline] {
          [Pipeline] timestamps
          [Pipeline] {
          [Pipeline] timeout
          16:32:58 Timeout set to expire in 30 min
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Setup)
          [Pipeline] script
          [Pipeline] {
          [Pipeline] parallel
          [Pipeline] [foo] { (Branch: foo)
          [Pipeline] [bar] { (Branch: bar)
          [Pipeline] [foo] timeout
          16:32:58 [foo] Timeout set to expire in 1 min 0 sec
          [Pipeline] [foo] {
          [Pipeline] [bar] sh
          16:32:58 [bar] [dummy] Running shell script
          [Pipeline] [foo] sh
          16:32:58 [bar] + sleep 200
          16:32:58 [foo] [dummy] Running shell script
          16:32:58 [foo] + sleep 90
          16:33:58 [foo] Cancelling nested steps due to timeout
          16:33:58 [bar] sh: line 1: 9756 Terminated: 15 JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-4d63fae2/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-4d63fae2/jenkins-log.txt' 2>&1
          16:33:58 [foo] Sending interrupt signal to process
          16:33:58 [foo] sh: line 1: 9762 Terminated: 15 JENKINS_SERVER_COOKIE=$jsc '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-76186e5f/script.sh' > '/Users/Shared/Jenkins/Home/workspace/dummy@tmp/durable-76186e5f/jenkins-log.txt' 2>&1
          [Pipeline] [bar] }
          16:34:07 [bar] Failed in branch bar
          [Pipeline] [foo] }
          [Pipeline] [foo] // timeout
          [Pipeline] [foo] }
          [Pipeline] // parallel
          [Pipeline] }
          [Pipeline] // script
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // timeout
          [Pipeline] }
          [Pipeline] // timestamps
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code 143
          Finished: FAILURE
          {code}
          abayer Andrew Bayer made changes -
          Component/s workflow-cps-plugin [ 21713 ]
          vivek Vivek Pandey made changes -
          Labels pipeline pipeline triaged-2018-11

            People

            • Assignee:
              Unassigned
              Reporter:
              aravinder111 Aravinder Bandi
            • Votes:
              6 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated: