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

LoadStatistics queue length and Cloud provisioning not working in conjunction with Node and Label parameter plugin

      The LoadStatistics.LoadStatisticsUpdater class updates the queueLength of each Label's LoadStatistics. It currently does the update by iterating over each of the BuildableItems in the queue and comparing their Task's assigned Label to the Label being updated and counting those that do (LoadStatistics.LoadStatisticsUpdater#count method).

      The "Node and Label parameter plugin" allows the Label assigned to a job to be selected when starting the build or to be passed in by the "Jenkins Parameterized Trigger plugin". When this is used the Label on the Task is null, and the selected label is reflected on the BuildableItem in the queue itself.

      This means that a Label selected using the Label parameter plugin always has LoadStatistics with a queue length of 0, and Cloud implementations are not requested to provision more nodes.

      I have done some testing with the Label parameter plugin disabled (using the Groovy script below) and it appears that the Tasks and BuildableItems matching the label appear to be equal across the labels.

      Jenkins j = Jenkins.getInstance();
      List<hudson.model.Queue.BuildableItem> bis = j.getQueue().getBuildableItems();
      println("Q length = " + bis.size());
      
      for(Label l : j.getLabels())
      {
        println(l.getExpression() + ":");
          
        int b=0,t=0;
        for (hudson.model.Queue.BuildableItem bi : bis) {
          if(bi.getAssignedLabel()==l)
                b++;
          if(bi.task.getAssignedLabel()==l)
                t++;
        }
        
        println("\tTasks matching label = " + t);
        println("\tBuilableItems matching label = " + b);
      }
      

      Is it correct that the LoadStatistics.LoadStatisticsUpdater#count method could be changed to call BuildableItem#getAssignedLabel rather than Task#getAssignedLabel?

          [JENKINS-15576] LoadStatistics queue length and Cloud provisioning not working in conjunction with Node and Label parameter plugin

          Jesse, I'm quite sure you have a better understanding of the LoadStatistics - do you think the proposed solution would help?

          Dominik Bartholdi added a comment - Jesse, I'm quite sure you have a better understanding of the LoadStatistics - do you think the proposed solution would help?

          Jesse Glick added a comment -

          @domi I am not familiar with this code, sorry.

          Jesse Glick added a comment - @domi I am not familiar with this code, sorry.

          Ivan Kalinin added a comment -

          That's quite a major issue indeed. Does anyone have a workaround?

          Ivan Kalinin added a comment - That's quite a major issue indeed. Does anyone have a workaround?

          Daniel Beck added a comment -

          Daniel Beck added a comment - Proposed pull request: https://github.com/jenkinsci/jenkins/pull/620

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3686
          [FIXED JENKINS-15576] Label's Load Statistics queue length based on (Revision b47f527ce9427218aecde544e0d5a196925cb892)
          Test cases for [FIXED JENKINS-15576] (Revision c49420e622facb8cc98e5f4447c0fc8ad6660990)

          Result = SUCCESS
          laurence.hey : b47f527ce9427218aecde544e0d5a196925cb892
          Files :

          • core/src/main/java/hudson/model/LoadStatistics.java
          • changelog.html

          laurence.hey : c49420e622facb8cc98e5f4447c0fc8ad6660990
          Files :

          • core/src/main/java/hudson/model/LoadStatistics.java
          • test/src/test/java/hudson/model/LabelLoadStatisticsQueueLengthTest.java
          • changelog.html
          • test/pom.xml

          dogfood added a comment - Integrated in jenkins_main_trunk #3686 [FIXED JENKINS-15576] Label's Load Statistics queue length based on (Revision b47f527ce9427218aecde544e0d5a196925cb892) Test cases for [FIXED JENKINS-15576] (Revision c49420e622facb8cc98e5f4447c0fc8ad6660990) Result = SUCCESS laurence.hey : b47f527ce9427218aecde544e0d5a196925cb892 Files : core/src/main/java/hudson/model/LoadStatistics.java changelog.html laurence.hey : c49420e622facb8cc98e5f4447c0fc8ad6660990 Files : core/src/main/java/hudson/model/LoadStatistics.java test/src/test/java/hudson/model/LabelLoadStatisticsQueueLengthTest.java changelog.html test/pom.xml

          fixed since a long time...

          Dominik Bartholdi added a comment - fixed since a long time...

            Unassigned Unassigned
            laurence_ Laurence Hey
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: