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

Make Label Linked Jobs plugin compatible with Jenkins Clouds definition

      With fixed slaves, Label Linked Jobs dashboard shows available labels and the jobs associated with them correctly.

      But when slaves are temporary - created on-demand when a job starts, then destroyed when the job is complete - those labels do not appear in the Label Linked Jobs dashboard. For example, the Docker Plugin allows creating a "cloud" where the "cloud" contains slaves that will be created from docker containers on demand. Each slave does have a label string associated with, just like a normal slave.

      Not sure if the Jenkins generic cloud has a way of getting the labels or not. There are other plugins that create slaves on demand; they may have the same problem as the Docker Plugin.

          [JENKINS-32445] Make Label Linked Jobs plugin compatible with Jenkins Clouds definition

          Hello

          The plugin is not meant to be compatible out of the box with all features and plugins of Jenkins, so I consider this requirement as an Improvement rather than a Bug .

          It would indeed be interesting to make the plugin able to gather data from Clouds' definitions.
          As you suspected however there is very little data available to the plugin via generic Jenkins APIs. In fact I can see only one relevant function, canProvision(Label) which could be used to detect if a Label defined by a job is also supported by a Cloud, and to determine whether a job cannot be executed at all because no fixed slaves nor Clouds support it.
          Note that this generic Jenkins API works only at the Cloud level, it doesn't allow granularity at template's level, which may be a concept specific to the Docker plugin.

          Considering this, what would you suggest for the dashboard?

          Dominique Brice added a comment - Hello The plugin is not meant to be compatible out of the box with all features and plugins of Jenkins, so I consider this requirement as an Improvement rather than a Bug . It would indeed be interesting to make the plugin able to gather data from Clouds' definitions. As you suspected however there is very little data available to the plugin via generic Jenkins APIs . In fact I can see only one relevant function, canProvision(Label) which could be used to detect if a Label defined by a job is also supported by a Cloud, and to determine whether a job cannot be executed at all because no fixed slaves nor Clouds support it. Note that this generic Jenkins API works only at the Cloud level, it doesn't allow granularity at template 's level, which may be a concept specific to the Docker plugin. Considering this, what would you suggest for the dashboard?

          Note: I took the liberty to change this issue name & type, and I cross-referenced it in the plugin page.

          Dominique Brice added a comment - Note: I took the liberty to change this issue name & type, and I cross-referenced it in the plugin page .

          Jason Swager added a comment -

          You are correct, this really is a feature - not a bug.

          I'm not sure if this would work, but perhaps for every label or combination of labels that the Linked Jobs plugin is processing, it could do a canProvision() on that label against each Cloud instance that's currently registered in Jenkins. If a Cloud responds affirmative, then the dashboard could just note the Clouds that support that combination. The dashboard wouldn't be able to tell how many nodes would support the label combination in that particular Cloud, but it would at least know that it can be handled.

          This logic could be used to determine if orphan jobs (jobs that have no runnable node) are really orphans or if some cloud can support them.

          Jason Swager added a comment - You are correct, this really is a feature - not a bug. I'm not sure if this would work, but perhaps for every label or combination of labels that the Linked Jobs plugin is processing, it could do a canProvision() on that label against each Cloud instance that's currently registered in Jenkins. If a Cloud responds affirmative, then the dashboard could just note the Clouds that support that combination. The dashboard wouldn't be able to tell how many nodes would support the label combination in that particular Cloud, but it would at least know that it can be handled. This logic could be used to determine if orphan jobs (jobs that have no runnable node) are really orphans or if some cloud can support them.

          Dominique Brice added a comment - - edited

          It seems technically doable.

          Dominique Brice added a comment - - edited It seems technically doable.

          Dominique Brice added a comment - https://github.com/jenkinsci/label-linked-jobs-plugin/commits/feature/JENKINS-32445

          jswager1, do you have a sandbox instance of jenkins where you could test a new version of the plugin with realistic clouds settings?
          Since I don't use clouds, my test cases may be missing some settings that occur in "production" environments. Let me know if you have the possibility to test a dev/snapshot version of the plugin, and I'll upload it to jenkins plugins snapshot repository.

          Dominique Brice added a comment - jswager1 , do you have a sandbox instance of jenkins where you could test a new version of the plugin with realistic clouds settings? Since I don't use clouds, my test cases may be missing some settings that occur in "production" environments. Let me know if you have the possibility to test a dev/snapshot version of the plugin, and I'll upload it to jenkins plugins snapshot repository .

          Dominique Brice added a comment - - edited

          I added two things that are visible:

          • on the labels dashboard, if there is at least one cloud defined in the Jenkins instance, each label has an indication to give the number of clouds which can provision it (see screenshot)
          • on the labels linked jobs, cloud(s) able to provision each label listed (atomic or composite) is/are listed (see screenshot)

          Provisioning clouds are also taken into account to determine the list of orphaned jobs on the dashboard.

          A snapshot plugin version with this new feature is available there.

          Dominique Brice added a comment - - edited I added two things that are visible: on the labels dashboard, if there is at least one cloud defined in the Jenkins instance, each label has an indication to give the number of clouds which can provision it (see screenshot) on the labels linked jobs, cloud(s) able to provision each label listed (atomic or composite) is/are listed (see screenshot) Provisioning clouds are also taken into account to determine the list of orphaned jobs on the dashboard. A snapshot plugin version with this new feature is available there .

          Jason Swager added a comment -

          dominiquebrice - sorry for the delay in response. Yes, I do have a sandbox instance where I can try out these changes. I loaded the snapshot version of the plugin and it worked rather well. Instead of seeing jobs that appear orphaned because they linked to labels on cloud providers, they now report the number of clouds and which ones can support them.

          This looks like a successful feature implementation to me! Thanks much!

          Jason Swager added a comment - dominiquebrice - sorry for the delay in response. Yes, I do have a sandbox instance where I can try out these changes. I loaded the snapshot version of the plugin and it worked rather well. Instead of seeing jobs that appear orphaned because they linked to labels on cloud providers, they now report the number of clouds and which ones can support them. This looks like a successful feature implementation to me! Thanks much!

          Code changed in jenkins
          User: Dominique
          Path:
          pom.xml
          src/main/java/jenkins/plugins/linkedjobs/actions/LabelDashboardAction.java
          src/main/java/jenkins/plugins/linkedjobs/actions/LabelLinkedJobsAction.java
          src/main/java/jenkins/plugins/linkedjobs/model/JobsGroup.java
          src/main/java/jenkins/plugins/linkedjobs/model/LabelAtomData.java
          src/main/resources/jenkins/plugins/linkedjobs/actions/LabelDashboardAction/index.jelly
          src/main/resources/jenkins/plugins/linkedjobs/actions/LabelLinkedJobsAction/index.jelly
          http://jenkins-ci.org/commit/label-linked-jobs-plugin/2605635e1f7252ee444420d8ebaaa734c6e379ed
          Log:
          Merge pull request #4 from jenkinsci/feature/JENKINS-32445

          JENKINS 32445 basic support for clouds

          Compare: https://github.com/jenkinsci/label-linked-jobs-plugin/compare/1842c5b0ff15...2605635e1f72

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dominique Path: pom.xml src/main/java/jenkins/plugins/linkedjobs/actions/LabelDashboardAction.java src/main/java/jenkins/plugins/linkedjobs/actions/LabelLinkedJobsAction.java src/main/java/jenkins/plugins/linkedjobs/model/JobsGroup.java src/main/java/jenkins/plugins/linkedjobs/model/LabelAtomData.java src/main/resources/jenkins/plugins/linkedjobs/actions/LabelDashboardAction/index.jelly src/main/resources/jenkins/plugins/linkedjobs/actions/LabelLinkedJobsAction/index.jelly http://jenkins-ci.org/commit/label-linked-jobs-plugin/2605635e1f7252ee444420d8ebaaa734c6e379ed Log: Merge pull request #4 from jenkinsci/feature/ JENKINS-32445 JENKINS 32445 basic support for clouds Compare: https://github.com/jenkinsci/label-linked-jobs-plugin/compare/1842c5b0ff15...2605635e1f72

          New plugin version published with this fix: 5.0.1.

          Dominique Brice added a comment - New plugin version published with this fix: 5.0.1 .

            dominiquebrice Dominique Brice
            jswager1 Jason Swager
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: