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

Developer wants to see a message when Jenkins is busy eg: execution is blocked waiting for a node

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Critical Critical
    • blueocean-plugin
    • None
    • frank, tethys, christmas, pannonian

      Problem
      When Jenkins is working, for example waiting for a node, a user is given no feedback as to what is happening. Currently this is a generic "waiting for run to start" message.
      This is not captured in any steps logs currently.

      What we want to see
      We want to show an appropriate message when a Pipeline is waiting for a node "Waiting for a node labeled XYZ to become available", and any other missing information that is not currently surfaces in step logs.

      Examples
      For example with a simple pipeline:

      node ('does not exist or busy') {
        sh 'echo hello world'
      }
      

      which currently looks like:

      In classic console it shows:

      Started by user mic
      [Pipeline] node
      Still waiting to schedule task
      Waiting for next available executor
      

      Ideally we can surface this information (who started it) but also that it is waiting for an executor, but also what the label expression/other deatils are.

      This should happen anywhere a node is requested (as one example) not just at the start of a build (so not an empty state).
      This could surface as a flownode which could be shown similar to a step (a synthetic step?)

      Another example:

      kzantow/failure-broject - branch name "michaelneale-blockscoped" when running that, the following information is omitted which could be useful:

      Started by user mic
      Connecting to https://api.github.com using michaelneale/******
      Cloning the remote Git repository
      Cloning repository https://github.com/kzantow/failure-project.git
       ...
      [Pipeline] node
      Running on master in /Users/michaelneale/projects/paas/blueocean-plugin/blueocean/work/workspace/keitha/michaelneale-blockscoped
      

      And on conclusion of the build, a warning (valid) is not seen in step output:

      Using the ‘stage’ step without a block argument is deprecated
      Entering stage Archive
      Proceeding
      

      Yet these warnings would also be useful.

          [JENKINS-40466] Developer wants to see a message when Jenkins is busy eg: execution is blocked waiting for a node

          Ryan Campbell added a comment -

          It's unclear to me how this is supposed to work for non-initial stages or parallel node acquisition.

          Ryan Campbell added a comment - It's unclear to me how this is supposed to work for non-initial stages or parallel node acquisition.

          Michael Neale added a comment -

          jamesdumay we need to flesh this out a bit - as there are many cases where this "state" could happen, not just at the start. As Ryan said, it could be in mid pipeline and then need to obtain another node (eg in parallel) and get into this state. or some other infra could fail that would be relevant to show.

          I think we need to reword this to be more general to get information as to what jenkins is doing into the flow nodes that blue ocean uses

          Michael Neale added a comment - jamesdumay we need to flesh this out a bit - as there are many cases where this "state" could happen, not just at the start. As Ryan said, it could be in mid pipeline and then need to obtain another node (eg in parallel) and get into this state. or some other infra could fail that would be relevant to show. I think we need to reword this to be more general to get information as to what jenkins is doing into the flow nodes that blue ocean uses

          James Dumay added a comment -

          michaelneale recampbell totally agree - there's a bunch of cases here but I don't know what they are. Seeking advice from the Pipeline experts

          James Dumay added a comment - michaelneale recampbell totally agree - there's a bunch of cases here but I don't know what they are. Seeking advice from the Pipeline experts

          James Dumay added a comment -

          vivek when we do this I think we certainly want to represent it as a step or tie it to the nearest flownode that caused the message.

          node ('something') {
          stage('A') {
            node('first agent') {
            }
          }
          
          stage('B') {
            node('first agent') {
            }
          }
          
          stage('C') {
            node('first agent') {
            }
          }
          }
          
          • waiting message for the "something" node should be for the whole pipeline (displayed as we do now with an empty state)
          • A, B, C waiting messages should be tied to that stage, perhaps as a step so that we can show it inline with other steps.

          We also need to explore other ways execution could be blocked. waiting on a node is one but are there more?

          James Dumay added a comment - vivek when we do this I think we certainly want to represent it as a step or tie it to the nearest flownode that caused the message. node ( 'something' ) { stage( 'A' ) { node( 'first agent' ) { } } stage( 'B' ) { node( 'first agent' ) { } } stage( 'C' ) { node( 'first agent' ) { } } } waiting message for the "something" node should be for the whole pipeline (displayed as we do now with an empty state) A, B, C waiting messages should be tied to that stage, perhaps as a step so that we can show it inline with other steps. We also need to explore other ways execution could be blocked. waiting on a node is one but are there more?

          Jesse Glick added a comment -

          other ways execution could be blocked. waiting on a node is one but are there more?

          Endless other ways.

          Jesse Glick added a comment - other ways execution could be blocked. waiting on a node is one but are there more? Endless other ways.

          Jesse Glick added a comment -

          also what the label expression/other deatils are

          If there is anything missing, that would be a core bug, since that is where this CauseOfBlockage lives. The node step simply reports the message it is given.

          Jesse Glick added a comment - also what the label expression/other deatils are If there is anything missing, that would be a core bug, since that is where this CauseOfBlockage lives. The node step simply reports the message it is given.

          James Dumay added a comment -

          Didn't mean to close this. Reopened.

          James Dumay added a comment - Didn't mean to close this. Reopened.

          James Dumay added a comment -

          vivek examples from today

          pipeline {
            agent { label 'foo' } // While pipeline is blocked, solved by showing the message (no steps) that we have today
            stages {
              stage ('first') {
                agent { label 'bar'}
              }
              stage ('second') {
                parallel(
                  "foo": {
                    agent { label 'baz' }
                  }
                )
              }
            }
          }
          
          // agent at pipeline level 
          
          node ('foo') {
            stage(first) { ... }
            stage(second) { ... }
          }
          
          // how this translates from Script to Declarative
          
          stage ('first') { // StartNode
            node ('bar') { // We know that this is executing? If so we want to display a synthetic step with CauseOfBlockage msg
              // Steps
            }
          }
          

          James Dumay added a comment - vivek examples from today pipeline { agent { label 'foo' } // While pipeline is blocked, solved by showing the message (no steps) that we have today stages { stage ( 'first' ) { agent { label 'bar' } } stage ( 'second' ) { parallel( "foo" : { agent { label 'baz' } } ) } } } // agent at pipeline level node ( 'foo' ) { stage(first) { ... } stage(second) { ... } } // how this translates from Script to Declarative stage ( 'first' ) { // StartNode node ( 'bar' ) { // We know that this is executing? If so we want to display a synthetic step with CauseOfBlockage msg // Steps } }

          Vivek Pandey added a comment -

          jglick I need to map a queued item corresponding to a node block to the FlowNode that is 'node' step. I need to do this so that I can show cause of failure to the stage whose execution is blocked.

          Only way I think I can do is if I can get access to StepContext from PlaceholderTask object. Its private field. Can we expose it, something like StepContext PlaceholderTask.getContext()? This will let me do StepContext.get(flowNode) and associate it to the actual flow node so that I can associate it to right stage?

          Here is the example declarative script. In this case we want to show stage 'first' as 'waiting for executor'.

          pipeline {
            agent none
            stages {
              stage ('first') {
               agent { 
                label 'first' 
               }
               steps{
                    sh 'echo "from first"'
                }
              }
            }
          }
          

          Vivek Pandey added a comment - jglick I need to map a queued item corresponding to a node block to the FlowNode that is 'node' step. I need to do this so that I can show cause of failure to the stage whose execution is blocked. Only way I think I can do is if I can get access to StepContext from PlaceholderTask object. Its private field. Can we expose it, something like StepContext PlaceholderTask.getContext()? This will let me do StepContext.get(flowNode) and associate it to the actual flow node so that I can associate it to right stage? Here is the example declarative script. In this case we want to show stage 'first' as 'waiting for executor'. pipeline { agent none stages { stage ( 'first' ) { agent { label 'first' } steps{ sh 'echo "from first" ' } } } }

          Vivek Pandey added a comment -

          Include synthetic step in blocked stage node with name equal to reason for blockage.

          Vivek Pandey added a comment - Include synthetic step in blocked stage node with name equal to reason for blockage.

            vivek Vivek Pandey
            jamesdumay James Dumay
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: