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.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major

      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
      

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

          Aravinder Bandi created issue -
          Aravinder Bandi made changes -
          Description Original: 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}
          New: 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}
          Andrew Bayer made changes -
          Component/s New: workflow-cps-plugin [ 21713 ]
          Vivek Pandey made changes -
          Labels Original: pipeline New: pipeline triaged-2018-11

            Unassigned Unassigned
            aravinder111 Aravinder Bandi
            Votes:
            9 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: