Werk #15662: Bug fixes for cmk.gui.plugins.metrics.utils.indexed_color

Component Metrics system
Title Bug fixes for cmk.gui.plugins.metrics.utils.indexed_color
Date Apr 27, 2023
Checkmk Edition Checkmk Raw (CRE)
Checkmk Version 2.2.0b6 2.3.0b1
Level Trivial Change
Class Bug Fix
Compatibility Incompatible - Manual interaction might be required

This werk is mainly relevant to users who deploy or develop custom Checkmk plugins. For all other users, the werk might result in some changes regarding the colors of certain metrics in graphs.

The above mentioned function, also available via cmk.gui.plugins.metrics.indexed_color, computes colors for graphs. It was buggy in multiple ways:

  • There was no validation of the input arguments idx and total. We now ensure that 0 <= idx <= total and total > 0. If these requirements are violated, an error is raised.
  • indexed_color crashed for certain (valid) parameter combinations. For small values of idx, indexed_color returns values from a fixed set of pre-defined colors. Once this set was exhausted, the function crashed if idx was close to total.
  • Depending on the value of total, indexed_color produced very dark colors after exhausting the pre-defined set. Instead, we now always start with the same brightness and then then become successively darker.

To the list of all Werks