mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 14:20:56 +00:00
fix(telemetry): stop the dashboard lint passing when it checked nothing
Run with no arguments the script iterated an empty list, found no violations and printed "OK: 0 dashboard(s) passed" with exit 0 -- a clean bill of health for reading no files, indistinguishable from a real pass. A bare run now defaults to every dashboard beside the script, and a run that still ends up with nothing to check exits 2 rather than reporting success. Passing paths explicitly behaves as before.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
"""Dashboard lint: cumulative metrics must be rate()-wrapped; tier filters present."""
|
||||
|
||||
import json, re, sys
|
||||
from pathlib import Path
|
||||
|
||||
# Prometheus gauges that hold a CUMULATIVE total -> must be rate()/increase()-wrapped.
|
||||
CUMULATIVE_PREFIXES = (
|
||||
@@ -111,8 +112,23 @@ def check(path, forbid_5m):
|
||||
|
||||
|
||||
def main():
|
||||
"""Validate the dashboards named on the command line, or all of them.
|
||||
|
||||
Exit status: 0 every dashboard passed, 1 violations were found, 2 there was
|
||||
nothing to validate. The last is an error rather than a pass: reporting
|
||||
success without having read a single dashboard is indistinguishable from a
|
||||
clean run, so a caller that mis-spells a path gets a green light for work
|
||||
that never happened.
|
||||
"""
|
||||
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
||||
forbid_5m = "--no-5m" in sys.argv
|
||||
if not args:
|
||||
# Default to every dashboard beside this script, so a bare run checks
|
||||
# the whole set instead of iterating an empty list.
|
||||
args = sorted(str(p) for p in Path(__file__).resolve().parent.glob("*.json"))
|
||||
if not args:
|
||||
print("ERROR: no dashboard JSON files to validate", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
all_errs = []
|
||||
for path in args:
|
||||
all_errs += check(path, forbid_5m)
|
||||
|
||||
Reference in New Issue
Block a user