DEV Community

ilya mozerov
ilya mozerov

Posted on

An UNKNOWN that kept the wrong reason

Mishe watches its own parts with small checks. Each check runs on a timer, writes a verdict into a signal (GREEN, RED or UNKNOWN), and a dashboard shows the signal with its reason. A check can also say "I cannot tell": its input is stale or missing, so it declares UNKNOWN rather than a false GREEN. That is the right behaviour. The reason shown next to the UNKNOWN is where it went wrong.

Two repairs in one week, both small, both found by reading the dashboard instead of the code.

The reason that never updated

A check that could not observe would exit with a declared "unknown" code. The runner did the right thing with the signal: it marked it UNKNOWN. But when the signal was already UNKNOWN, the runner left the old reason in place. The old reason was whatever the signal had recorded first, something like "expired after 900s without observation", which is true about the age of the last reading and says nothing about why the check is failing now.

So the dashboard said the input had gone stale, when the check had written a precise cause into its own detail file: which device had not reported, and why. The runner read that file only to log it, and never copied the cause into the signal.

The fix is one rule. An already-UNKNOWN signal takes the check's own brief detail as its reason. A fresh GREEN still ages out to UNKNOWN as declared, so nothing that really went stale is hidden.

The reason that changed every five minutes

The first fix introduced the second bug. The check's detail contained ages and epoch counters, for example "last report 312s ago". Every five-minute run produced a slightly different string, so every run rewrote the reason. Subscribers were woken by an edge that meant nothing: the cause had not changed, only the number in it.

The repair compares causes with the digits removed. A repeated identical cause writes nothing. A genuinely new cause is still an edge.

The removal used a regular expression at first, and the repository has a rule that forbids regular expressions outside approved parsing adapters. The continuous integration run went red on that commit for the one reason the rule exists. The replacement is a plain loop that collapses runs of digits. The tests for the comparison did not change and still pass.

What to take from it

  • An UNKNOWN is an observation, and it needs a reason as true as a GREEN one. Age is not a cause.
  • Comparing a status by its text makes noise unless you strip the parts that move on every run. Decide what counts as a change before you write the comparison.
  • A rule written for a reason ("keep parsing at the boundary") is easy to break in a one-line fix. The check that enforces it is what caught it, not a reviewer.

These fixes are in the running release now. The next time a check goes UNKNOWN, the dashboard should say why, and it should not rewrite its reason every five minutes. If it does one or the other, that is a bug, and the reading that shows it is on the dashboard.

Top comments (0)