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

Labels view not refreshed when labels are added to a node (causing some time installer failure for ephemeral agents)

    • 2616.v07df00c08d42

      Hi,

      Took me a while to understand why tools were not installed on running agent even if the labels were set on the node.

      I happen that the https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/tools/ToolInstaller.java#L87 doesn't consider assigned labels (Typically the ones created by LabelFinder extensions). Like https://github.com/jenkinsci/platformlabeler-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/platformlabeler/PlatformLabeler.java#L40

      It's specially true of ephemeral agent and tool directive installation. Dynamic labels are assigned "too late" on the build.

      I propose to change it to (not tested)

      public boolean appliesTo(Node node) {
         Label l = Jenkins.get().getLabel(label);
         return l == null || node.getAssignedLabels().contains(l);
      }
      

       

      Any thought ?

        1. label.PNG
          label.PNG
          6 kB
        2. label2.PNG
          label2.PNG
          25 kB

          [JENKINS-72224] Labels view not refreshed when labels are added to a node (causing some time installer failure for ephemeral agents)

          Markus Winter added a comment -

          The label could be a labelexpression e.g. a || b

          With your change this would never match whereas the existing approach should work also for label expressions.

          Dynamic labels from the platform labeler plugin are only be applied when the agent becomes online and then it takes a moment until the labels get applied. So as you already noticed the assignment might be too late when the tool installation is done right at the beginning of the pipeline.

          Sometimes I've seen that Jenkins takes quite a while (~ 20-30s) until a node appeared in a label in the UI after adding the label to the node.

          Markus Winter added a comment - The label could be a labelexpression e.g. a || b With your change this would never match whereas the existing approach should work also for label expressions. Dynamic labels from the platform labeler plugin are only be applied when the agent becomes online and then it takes a moment until the labels get applied. So as you already noticed the assignment might be too late when the tool installation is done right at the beginning of the pipeline. Sometimes I've seen that Jenkins takes quite a while (~ 20-30s) until a node appeared in a label in the UI after adding the label to the node.

          Thanks for the hints.

          I'm wonder if there is any fix on core or on this case the platform labeler.

          I found there is https://javadoc.jenkins.io/hudson/slaves/ComputerListener.html#preOnline(hudson.model.Computer,hudson.remoting.Channel,hudson.FilePath,hudson.model.TaskListener)

          I'm wonder if we can collect labels earlier in the process.

          Will assign also `platformlabeler-plugin` just in case.

          Regards,

          Valentin Delaye added a comment - Thanks for the hints. I'm wonder if there is any fix on core or on this case the platform labeler. I found there is https://javadoc.jenkins.io/hudson/slaves/ComputerListener.html#preOnline(hudson.model.Computer,hudson.remoting.Channel,hudson.FilePath,hudson.model.TaskListener) I'm wonder if we can collect labels earlier in the process. Will assign also ` platformlabeler-plugin ` just in case. Regards,

          Markus Winter added a comment -

          using preOnline in the platformlabeler should be an option. How about opening PR there.

          Markus Winter added a comment - using preOnline in the platformlabeler should be an option. How about opening PR there.

          Valentin Delaye added a comment - https://github.com/jenkinsci/platformlabeler-plugin/pull/1170

          Fix done on platformlabeler 2287.va_d728a_42d7f1

          Valentin Delaye added a comment - Fix done on platformlabeler 2287.va_d728a_42d7f1

          I'm reopening this issue because it still cause issue with tool installer.

          Even when labels are assigned correctly to the node (before it connects) platformlabeler 2287.va_d728a_42d7f1

          When I check on the Jenkins UI I can see the following on the /computer/<node> page

          • When checking on the node page, the labels are always assigned (including implied one)

          This doesn't seems the issue

          But when checking the label page (the one that list the node using the label) /label/<label>/

          I cannot see my node listed. Even if it's online

          So I confirm that sometimes it work, sometimes not. It looks timing dependent 

          Does anyone as any idea ? Is there a way to "flush" this refresh from the platform labeler to ensure we can see the nodes on the label page directly when labels are assigned ?

          On 

          Valentin Delaye added a comment - I'm reopening this issue because it still cause issue with tool installer. Even when labels are assigned correctly to the node (before it connects) platformlabeler  2287.va_d728a_42d7f1 When I check on the Jenkins UI I can see the following on the /computer/<node> page When checking on the node page, the labels are always assigned (including implied one) This doesn't seems the issue But when checking the label page (the one that list the node using the label) /label/<label>/ I cannot see my node listed. Even if it's online So I confirm that sometimes it work, sometimes not. It looks timing dependent  Does anyone as any idea ? Is there a way to "flush" this refresh from the platform labeler to ensure we can see the nodes on the label page directly when labels are assigned ? On 

          Hi mawinter69 

          By any chance do you have any idea related to my last comment ? Why even labels are assigned to a new, the node is not visible from the label view immediatly ? Do you know if there is some recurring tasks updating labels ? And ideally if there would be some API public method to refresh those labels we can use from the platform labeler plugin ?

          Thanks for your hints!

          Valentin Delaye added a comment - Hi mawinter69   By any chance do you have any idea related to my last comment ? Why even labels are assigned to a new, the node is not visible from the label view immediatly ? Do you know if there is some recurring tasks updating labels ? And ideally if there would be some API public method to refresh those labels we can use from the platform labeler plugin ? Thanks for your hints!

          I've open a PR here: https://github.com/jenkinsci/platformlabeler-plugin/pull/1389

          Not sure if it's the best way, but it works

          Valentin Delaye added a comment - I've open a PR here: https://github.com/jenkinsci/platformlabeler-plugin/pull/1389 Not sure if it's the best way, but it works

          Should be full fixed on 2616.v07df00c08d42

          Valentin Delaye added a comment - Should be full fixed on 2616.v07df00c08d42

            jonesbusy Valentin Delaye
            jonesbusy Valentin Delaye
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: