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

Double-counting of health reports from child folders

      Folder.getBuildHealthReports looks like it is double-counting each child Folder. It does a recursive traversal of the folder, applying FolderHealthMetric.Reporter to each node (leaf or not). But a typical FolderHealthMetric like WorstChildHealthMetric also calls getHealthReport on the child Folder, which winds up calling Folder.getBuildHealthReports recursively! This seems like a mistake.

      Possible fixes:

      • Make WorstChildHealthMetric.ReporterImpl.observe (and any other similar impls) ignore a Folder it is given.
      • Make Folder.getBuildHealthReports not ask a reporter to observe a Folder.
      • Make Folder.getBuildHealthReports not do a recursive traversal, only asking about direct children.

      My preference is for the third fix, as it leaves the reporter in control of the logic; if it needs a recursive call it can do one.

      By the way, the awkward reflection code in getHealthReport suggests that we need an interface in Jenkins core, such as

      interface ItemWithHealthReport extends Item {
          HealthReport getBuildHealth();
          List<HealthReport> getBuildHealthReports();
      }
      

          [JENKINS-25073] Double-counting of health reports from child folders

          Jesse Glick created issue -
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-25075 [ JENKINS-25075 ]

          Jesse Glick added a comment -

          AverageChildHealthMetric in cloudbees-folders-plus already implements the first fix. (Oddly WorstChildHealthMetric did not get the analogous change.) This complicates doing the third fix a bit as old versions of cloudbees-folders-plus with new versions of cloudbees-folder would behave incorrectly (at least, not recursively) in AverageChildHealthMetric; however the regression would be pretty minor, and corrected simply by upgrading both.

          Jesse Glick added a comment - AverageChildHealthMetric in cloudbees-folders-plus already implements the first fix. (Oddly WorstChildHealthMetric did not get the analogous change.) This complicates doing the third fix a bit as old versions of cloudbees-folders-plus with new versions of cloudbees-folder would behave incorrectly (at least, not recursively) in AverageChildHealthMetric ; however the regression would be pretty minor, and corrected simply by upgrading both.

          Jesse Glick added a comment -

          Fix #3 would also be incompatible for, say, ProjectEnabledHealthMetric which logically should check for all (top-level?) contained AbstractProject instances, but is written to only consider the Item it is given. So while I do not like this API design it may be too late to change.

          Fix #2 could also be incompatible in principle.

          Jesse Glick added a comment - Fix #3 would also be incompatible for, say, ProjectEnabledHealthMetric which logically should check for all (top-level?) contained AbstractProject instances, but is written to only consider the Item it is given. So while I do not like this API design it may be too late to change. Fix #2 could also be incompatible in principle.
          Jesse Glick made changes -
          Labels Original: health performance New: api health performance
          Jesse Glick made changes -
          Assignee Original: Stephen Connolly [ stephenconnolly ] New: Jesse Glick [ jglick ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/main/java/com/cloudbees/hudson/plugins/folder/health/FolderHealthMetric.java
          src/main/java/com/cloudbees/hudson/plugins/folder/health/WorstChildHealthMetric.java
          http://jenkins-ci.org/commit/cloudbees-folder-plugin/832860377665641de69fcc8848f7ce342ca980fd
          Log:
          [FIXED JENKINS-25073] Avoid double-counting health metrics from subfolders.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/com/cloudbees/hudson/plugins/folder/health/FolderHealthMetric.java src/main/java/com/cloudbees/hudson/plugins/folder/health/WorstChildHealthMetric.java http://jenkins-ci.org/commit/cloudbees-folder-plugin/832860377665641de69fcc8848f7ce342ca980fd Log: [FIXED JENKINS-25073] Avoid double-counting health metrics from subfolders.
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 158974 ] New: JNJira + In-Review [ 195953 ]

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: