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

          Laurence Hey created issue -
          Laurence Hey made changes -
          Assignee Original: Dominik Bartholdi [ domi ] New: Laurence Hey [ laurence_ ]
          Dominik Bartholdi made changes -
          Assignee Original: Laurence Hey [ laurence_ ] New: Jesse Glick [ jglick ]
          Jesse Glick made changes -
          Assignee Original: Jesse Glick [ jglick ]
          Daniel Beck made changes -
          Labels New: lts-candidate
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 146332 ] New: JNJira + In-Review [ 176587 ]
          Dominik Bartholdi made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Oliver Gondža made changes -
          Labels Original: lts-candidate
          Mark Waite made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

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

              Created:
              Updated:
              Resolved: