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

Sub Task Time in Queue is not getting captured in metrics plugin

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • metrics-plugin
    • metrics plugin 4.1.6.2
      jenkins 2.332.4
    • metrics:4.2.13-420.vea_2f17932dd6

      In previous versions of metrics plugin we were adding RunResolver to provide a run which was further used to add  SubTaskTimeInQueueAction as and when an item left the queue.

      In this version 4.1.6.2 we have observed that SubTaskTimeInQueueAction is only added in taskCompleted method under the condition if Work Unit is not main work https://github.com/jenkinsci/metrics-plugin/blob/metrics-4.1.6.2/src/main/java/jenkins/metrics/impl/JenkinsMetricProviderImpl.java#L1008 

      But due to above condition it is not adding any of the sub task time as if you consider the Jenkins core code in WorkUnitContext this task completed is called https://github.com/jenkinsci/jenkins/blob/jenkins-2.332.4/core/src/main/java/hudson/model/queue/WorkUnitContext.java#L177  under condition https://github.com/jenkinsci/jenkins/blob/jenkins-2.332.4/core/src/main/java/hudson/model/queue/WorkUnitContext.java#L171.

      ISSUE:-

      Essentially it means WorkUnitContext will call taskCompleted in the condition if Work unit is main work and in the metrics plugin we are checking if the Work Unit is not the main work only then add sub task times.

      Due to above scenario we see a regression and we are not able to see the sub task times being present and on the UI we only see the main queue time.

       

          [JENKINS-69817] Sub Task Time in Queue is not getting captured in metrics plugin

          Jesse Glick added a comment -

          Are you claiming a regression from https://github.com/jenkinsci/metrics-plugin/pull/126? Not clear to me what the concrete scenario here is, but apparently it lacks test coverage.

          Jesse Glick added a comment - Are you claiming a regression from https://github.com/jenkinsci/metrics-plugin/pull/126? Not clear to me what the concrete scenario here is, but apparently it lacks test coverage.

          Sunder Gopal Singh added a comment - - edited

          jglick No, I am telling a regression because of https://github.com/jenkinsci/metrics-plugin/pull/127 PR as it has changes related to that code and we have added the condition "!wu.isMainWork()" in that PR only.

          Sunder Gopal Singh added a comment - - edited jglick No, I am telling a regression because of https://github.com/jenkinsci/metrics-plugin/pull/127 PR as it has changes related to that code and we have added the condition "!wu.isMainWork()" in that PR only.

          I'm not sure whether this issue covers my scenario, using Metrics Plugin Version 4.2.10-389.v93143621b_050 on Jenkins 2.361.1.

          I have a declarative pipeline in which the pipeline block has agent none and two stages. The first stage ("Options") runs on the Jenkins controller and only sets some job properties. The second stage ("Agent") has agent { label 'windows' } and a few nested stages. If all suitable executors are busy, the pipeline runs the first stage ("Options") immediately and is then queued until an executor becomes available for the second stage ("Agent"). One build of the job was queued for 26 minutes in this way. The "Timings" page provided by the Metrics plugin shows:

            Primary task Including subtasks
          In queue: Waiting 0 ms 0 ms
          In queue: Blocked 0 ms 0 ms
          In queue: Buildable 0 ms 0 ms
          In queue: Total 11 ms 11 ms
          Building 44 min 44 min
          Scheduled to completion 44 min
          Number of subtasks 0
          Average executor utilization 1.0

          I somewhat expect that the 26 minutes should show up in one of the "In queue" rows, and perhaps this issue causes them to be counted as "Building" instead. OTOH, "Number of subtasks" is also displayed as 0, so I may have misunderstood what this issue is about.

          Kalle Niemitalo added a comment - I'm not sure whether this issue covers my scenario, using Metrics Plugin Version 4.2.10-389.v93143621b_050 on Jenkins 2.361.1. I have a declarative pipeline in which the pipeline block has agent none and two stages. The first stage ("Options") runs on the Jenkins controller and only sets some job properties. The second stage ("Agent") has agent { label 'windows' } and a few nested stages. If all suitable executors are busy, the pipeline runs the first stage ("Options") immediately and is then queued until an executor becomes available for the second stage ("Agent"). One build of the job was queued for 26 minutes in this way. The "Timings" page provided by the Metrics plugin shows:   Primary task Including subtasks In queue: Waiting 0 ms 0 ms In queue: Blocked 0 ms 0 ms In queue: Buildable 0 ms 0 ms In queue: Total 11 ms 11 ms Building 44 min 44 min Scheduled to completion 44 min Number of subtasks 0 Average executor utilization 1.0 I somewhat expect that the 26 minutes should show up in one of the "In queue" rows, and perhaps this issue causes them to be counted as "Building" instead. OTOH, "Number of subtasks" is also displayed as 0, so I may have misunderstood what this issue is about.

          jglick I have made changes as per the previous code for checking the sub tasks. https://github.com/jenkinsci/metrics-plugin/pull/190/files You can review once and let me know if I am missing something

          Sunder Gopal Singh added a comment - jglick I have made changes as per the previous code for checking the sub tasks. https://github.com/jenkinsci/metrics-plugin/pull/190/files You can review once and let me know if I am missing something

          Fixed inhttps://github.com/jenkinsci/metrics-plugin/releases/tag/4.2.13-420.vea_2f17932dd6

          Allan BURDAJEWICZ added a comment - Fixed inhttps://github.com/jenkinsci/metrics-plugin/releases/tag/4.2.13-420.vea_2f17932dd6

            allan_burdajewicz Allan BURDAJEWICZ
            sundergopalsingh Sunder Gopal Singh
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: