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

Entering, then cancelling, quiet mode causes builds to hang

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • workflow-cps-plugin
    • None
    • jenkins:latest docker image

      This problem can be reproduced with a simple pipeline job that does nothing but echo and sleep in a loop.

      1) Start a run of the pipeline job, the job produces output in the Console Output as I expect
      2) Put Jenkins in "Preparing for Shutdown" mode. The jobs stop producing output. That's somewhat surprising, as runs that were started before entering Shutdown Mode are usually allowed to complete.
      3) Cancel "Shutdown Mode." The job is still "stuck" and doesn't produce any output. The job also cannot be canceled except by a "hard kill," i.e. going through the "Forcibly terminate running steps" and "Forcibly kill entire build" links

      The behavior in #2 is surprising, but not really a problem for me. However, the fact that entering and leaving shutdown mode completely hoses running jobs is really bad. This is compounded by an init.groovy script we use that places Jenkins in shutdown mode at startup.

          [JENKINS-38316] Entering, then cancelling, quiet mode causes builds to hang

          Steven Walter created issue -

          Brent Goodacre added a comment - - edited

          I've noticed this problem as well, it really makes "Prepare for shutdown" quite useless for us because it's tedious to have to hard kill our currently running jobs. The whole idea of "Prepare for shutdown" is to allow us to finish the currently running jobs, not freeze them where they are.

          It's worth calling out that this has only happened in a recent upgrade of either Jenkins or one of the Pipeline plugins (Sorry it's vague but I'd estimate a change in the last 1-2 months)

          Here is a workflow script to repro:

          1. Create and start a job that uses the following code:

          node( "testnode" )
          {
              for( int i = 0; i < 10; i++ )
              {
                  println "Sleep: ${i+1}"
                  sleep(5)
              }
          }
          

          2. Activate "Prepare for Shutdown" mode while the job is running.

          Expected Result: Job continues to run as it's already midway through execution.
          Actual Result: Job freezes

          srwalter this might not help you, but if you cancel "Prepare for Shutdown" and then on your job click "Pause/resume" to toggle the job into Paused, then Resumed states, the job will continue. Eg.

          Sleep: 3
          [Pipeline] sleep
          Sleeping for 5 sec
          Pausing
          Resuming
          [Pipeline] echo
          Sleep: 4
          [Pipeline] sleep
          Sleeping for 5 sec
          [Pipeline] echo
          Sleep: 5
          

          Brent Goodacre added a comment - - edited I've noticed this problem as well, it really makes "Prepare for shutdown" quite useless for us because it's tedious to have to hard kill our currently running jobs. The whole idea of "Prepare for shutdown" is to allow us to finish the currently running jobs, not freeze them where they are. It's worth calling out that this has only happened in a recent upgrade of either Jenkins or one of the Pipeline plugins (Sorry it's vague but I'd estimate a change in the last 1-2 months) Here is a workflow script to repro: 1. Create and start a job that uses the following code: node( "testnode" ) { for ( int i = 0; i < 10; i++ ) { println "Sleep: ${i+1}" sleep(5) } } 2. Activate "Prepare for Shutdown" mode while the job is running. Expected Result: Job continues to run as it's already midway through execution. Actual Result: Job freezes srwalter this might not help you, but if you cancel "Prepare for Shutdown" and then on your job click "Pause/resume" to toggle the job into Paused, then Resumed states, the job will continue. Eg. Sleep: 3 [Pipeline] sleep Sleeping for 5 sec Pausing Resuming [Pipeline] echo Sleep: 4 [Pipeline] sleep Sleeping for 5 sec [Pipeline] echo Sleep: 5

          Brian Saville added a comment - - edited

          To me, #3 is really the issue here. Due to the nature of pipeline jobs (serialized, stoppable at just about any point), it doesn't bother me that #2 happens. But cancelling the shutdown mode (without a restart) should cause the jobs to start back up again, and it currently doesn't.

          And it may go without saying, but we're seeing this issue too.

          Brian Saville added a comment - - edited To me, #3 is really the issue here. Due to the nature of pipeline jobs (serialized, stoppable at just about any point), it doesn't bother me that #2 happens. But cancelling the shutdown mode (without a restart) should cause the jobs to start back up again, and it currently doesn't. And it may go without saying, but we're seeing this issue too.
          Dan Alvizu made changes -
          Component/s New: pipeline [ 21692 ]
          Component/s Original: build-pipeline-plugin [ 15962 ]
          Jesse Glick made changes -
          Component/s New: workflow-cps-plugin [ 21713 ]
          Component/s Original: pipeline [ 21692 ]

          Jesse Glick added a comment -

          An effect of the fix of JENKINS-32015.

          Jesse Glick added a comment - An effect of the fix of JENKINS-32015 .
          Jesse Glick made changes -
          Link New: This issue blocks JENKINS-32015 [ JENKINS-32015 ]
          Jesse Glick made changes -
          Summary Original: Putting Jenkins in shutdown mode breaks running pipeline runs New: Entering, then cancelling, quiet mode causes builds to hang

          Jesse Glick added a comment -

          Freezing the build—that is, the Groovy part—is deliberate, to prevent far worse problems, since we do not know when the actual JVM exit is going to come (TBD if we can safely block TermMilestone.COMPLETED). But the possibility that this mode would subsequently be cancelled was never considered. Pause + Resume is the appropriate workaround.

          The whole idea of "Prepare for shutdown" is to allow us to finish the currently running jobs

          It is to allow you to finish currently running freestyle (Maven, matrix, …) builds. So if you /safeRestart Jenkins will restart as soon as any of those are completed, and running Pipeline builds will be left alone.

          Jesse Glick added a comment - Freezing the build—that is, the Groovy part—is deliberate, to prevent far worse problems, since we do not know when the actual JVM exit is going to come (TBD if we can safely block TermMilestone.COMPLETED ). But the possibility that this mode would subsequently be cancelled was never considered. Pause + Resume is the appropriate workaround. The whole idea of "Prepare for shutdown" is to allow us to finish the currently running jobs It is to allow you to finish currently running freestyle (Maven, matrix, …) builds. So if you /safeRestart Jenkins will restart as soon as any of those are completed, and running Pipeline builds will be left alone.
          Jesse Glick made changes -
          Epic Link New: JENKINS-35399 [ 171192 ]

            Unassigned Unassigned
            srwalter Steven Walter
            Votes:
            20 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved: