Skip to main content

How to disable the weather column to resolve instance slowness?

Comments

13 comments

  • Harald Göttlicher

    Hi, thanks for the hint, this really helps.

    If you only want to remove the health metrics from top level folder, you can add

      if (! (folder.getParent() instanceof com.cloudbees.hudson.plugins.folder.Folder) ) {

    So i.e. the script then is

    def folders = Jenkins.instance.getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class)
    folders.each{ folder ->
      if (! (folder.getParent() instanceof com.cloudbees.hudson.plugins.folder.Folder) ) {
        folder.healthMetrics.each{ metric ->
          if (!(metric instanceof com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric)) {
            println "Removing ${metric.class.simpleName} from ${folder.name}"
            folder.healthMetrics.remove(metric)
            folder.save()
          }
        }
      }
    }
    return null

    Similarly, we could check for a certain folder depth level.

     

    0
  • Harald Göttlicher

    Here's my improved script with

    • folder depth level option
    • dry run

    Have fun!

    // set max folder depth to fix - e.g. 2 will fix root and one subfolder level
    def maxDepth = 2
    // try dry run first, set false to apply changes
    def dryRun = true

    def folders = Jenkins.instance.getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class)
    folders.each{ folder ->
      // check if folder is deeper than max depth
      def depthReached = false
      def parent = folder.getParent()
      for (i = 1; i <= maxDepth; i++) {
        if (!(parent instanceof com.cloudbees.hudson.plugins.folder.Folder)) {
          // top level reached
          break
        }
        if (i==maxDepth) {
          // level > max depth, do not consider this folder
          depthReached = true
        }
        else {
          parent = parent.getParent()
        }
      }

      if (!depthReached) {
        println "Checking folder $folder.name..."
        folder.healthMetrics.each{ metric ->
          if (!(metric instanceof com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric)) {
            println "- ${dryRun?'Would remove':'Removing'} ${metric.class.simpleName} from ${folder.name}"
            if (!dryRun) {
              folder.healthMetrics.remove(metric)
              folder.save()
            }
          }
        }
      }
    }
    return null
    0
  • Chris-lee Chris-lee

    How would you do this in non-enterprise Jenkins? I was going to go rooting around to see if I could find the non-enterprise classes to replace, but that kinda scares me.

    0
  • Allan Burdajewicz

    Hi Chris-lee, 

    The script only requires that you have the CloudBees Folder plugin installed and this plugin is open source. It should therefore work on Jenkins LTS.

     

    0
  • Chris-lee Chris-lee

    As written the script executed gives me this:

     

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
    Script1.groovy: 4: unable to resolve class com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric 
     @ line 4, column 29.
           if (!(metric instanceof com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric))

    I presumed it was because I didn't have the cloudbees enterprise version. 

     

    I looked for the source and found "https://github.com/jenkinsci/cloudbees-folder-plugin/blob/master/src/main/java/com/cloudbees/hudson/plugins/folder/health/WorstChildHealthMetric.java"

    Which seems like it might be a renamed version of the same thing, and that was detected by the script but I don't know if that's the right thing to remove. When I remove it the column with the weather remains.

    0
  • Denys Digtiar
    com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric

    On a second look, this class is indeed defined in the CloudBees proprietary plugin. What you can try is to remove this condition completely and let script remove all the Health Metrics.

    0
  • Permanently deleted user

    To rollback:

    import com.cloudbees.hudson.plugins.folder.Folder;
    import com.cloudbees.hudson.plugins.folder.health.*;
    
    Jenkins.instance.getAllItems(Folder.class).each {
        it.healthMetrics.add(new WorstChildHealthMetric())
        it.healthMetrics.add(new AverageChildHealthMetric())
        it.healthMetrics.add(new ProjectEnabledHealthMetric())
        // cloudbees-folders-plus-plugin (this one is proprietary)
        it.healthMetrics.add(new JobStatusHealthMetric(true,true,true,true))
    
        it.save()
    }
    0
  • Junyi Sun

    Hello, I followed the instruction to go to a folder configuration page and I don't see anything under Health metrics.

    But I am still seeing the weather column (see the attachment). Any ideas why?

    Thanks

    Junyi

    0
  • Permanently deleted user

    Hi Junyi,

    This will stop the weather column from constantly refreshing on all folders and the jobs within them.

    It does not remove the icon.

    I hope this makes sense.

    1
  • Joe Miller

    I don't see a clear answer on how to disable this for non-enterprise installations.  I have the Cloudbees Folder plugin installed and that doesn't appear to have the classes detailed here. Thanks!

    0
  • Chen Fliesher

    I have an LTS versiob of jenkins with cloudbees-folder installed.

    I am using it on a Github Folder (Github Branch source Plugin)

    The problem that

    Jenkins.instance.getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class)
    doesn't return any folders.

    I tried to drilled down the Github branch source plugin, but couldn't find any relation to cloudbees folder.

    Anyone managed to pull this on a Github organation folder ?
    0
  • Denys Digtiar

    Joe, Chen

    The updated script should cover both of your use cases. 

    0
  • Steven Christenson

    We have 10 Jenkins masters ranging from
    CloudBees Jenkins Enterprise 2.176.4.3-rolling (the latest)
    to 
    CloudBees Jenkins Enterprise 2.164.2.1-rolling (an old soon to be retired master)

    Unfortunately the script supplied above did not remove ANY of the weather columns on any of our masters. I see above where it explains it stops the updating, but what it the point of having a Weather column that is out of date?

    "The only caveat of such a change is that the weather column will always report Folders as Healthy." is inaccurate. After using the Cloudbees supplied code, the weather will always report whatever the last status was when the metric was removed.  So it could be permanently Healthy or Permanently Bad.

    Secondarily, it would be very helpful if we could configure the "default" All view that folders are created with to: 

    Not look like this:


    Put the build button leftmost where it is easier to find.
    Not include Weather
    Not include "Favorites"
    Not include "Built On"
    Not include "# Issues"

    And finally, I'd like to understand the impact that the "Last (success/failure/duration)" times have on Jenkins master loads. If those are lightweight, I'd keep them, otherwise we need to lose them unless explicitly added to a view.


     

    1

Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.