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

BlueOcean API parallel node duration in ms incorrect in declarative pipeline

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • blueocean-plugin
    • None
    • Jenkins: CloudBees Jenkins Enterprise 2.46.24.0.2-fixed
      Pipeline - Declarative: 1.2.4
      Blue Ocean: 1.3.3

      When moving our pipeline from scripted to declarative, we've noticed that the node duration in milliseconds returned by the blue ocean rest API appears to be incorrect for parallel stages. It seems it may be reporting just the time to start the stage rather than the total duration.

      Example pipeline:

      pipeline {
        agent any
        stages {
          stage('parallel sleep') {
            parallel {
              stage('1') {
                steps {
                  sleep time: 1, unit: 'MINUTES'
                }
              }
              stage('2') {
                steps {
                  sleep time: 1, unit: 'MINUTES'
                }
              }
            }
          }
        }
      }
      

      Blue Ocean API (/blue/rest/blueocean-api-bug-test/runs/2/nodes/) returns:

      <snip>
        "displayName": "1",
        "durationInMillis": 171,
        "id": "9",
        "input": null,
        "result": "SUCCESS",
        "startTime": "2018-01-09T09:13:18.778+0000",
        "state": "FINISHED",
      <snip>

      Compared to an example in scripted:

      node('m1.medium') {
        stage('parallel sleep') {
          parallel([
            '1': {
              sleep time: 1, unit: 'MINUTES'
            },
            '2': {
              sleep time: 1, unit: 'MINUTES'
            },
          ])
        }
      }

      Blue Ocean API (/blue/rest/blueocean-api-bug-test/runs/3/nodes/) returns:

      <snip>
        "displayName": "1",
        "durationInMillis": 60274,
        "id": "9",
        "input": null,
        "result": "SUCCESS",
        "startTime": "2018-01-09T09:53:00.085+0000",
        "state": "FINISHED",
      <snip>

      It feels like a bug to me. If not a bug, then it feels like an inconsistency in behaviour unless I have done something horribly wrong in my implementation (likely! )

          [JENKINS-48859] BlueOcean API parallel node duration in ms incorrect in declarative pipeline

          Adam Roberts added a comment -

          Seeing the same issue, which makes metrics monitoring of stages harder as we have to manually calculate the parallel block time

          Adam Roberts added a comment - Seeing the same issue, which makes metrics monitoring of stages harder as we have to manually calculate the parallel block time

          Vivek Pandey added a comment -

          abayer svanoort Looks like there is an issue of what graph analysis expects and how declarative deals with computing parallel branch time?

          In blueocean this is how a branch timing is computed:

          https://github.com/jenkinsci/blueocean-plugin/blob/2c91571484e3524a1449719f9fdce059dbf1808d/blueocean-pipeline-api-impl/src/main/java/io/jenkins/blueocean/rest/impl/pipeline/PipelineNodeGraphVisitor.java#L263

          Vivek Pandey added a comment - abayer svanoort Looks like there is an issue of what graph analysis expects and how declarative deals with computing parallel branch time? In blueocean this is how a branch timing is computed: https://github.com/jenkinsci/blueocean-plugin/blob/2c91571484e3524a1449719f9fdce059dbf1808d/blueocean-pipeline-api-impl/src/main/java/io/jenkins/blueocean/rest/impl/pipeline/PipelineNodeGraphVisitor.java#L263

          Andrew Bayer added a comment -

          vivek - are you calculating that for the branch or for the stage within the branch?

          Andrew Bayer added a comment - vivek - are you calculating that for the branch or for the stage within the branch?

          kutzi added a comment -

          Is there any update on this?

          kutzi added a comment - Is there any update on this?

            Unassigned Unassigned
            rjbwtr Richard Bowater
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: