Color fleet monitor rows: green operational, yellow degraded, red down
Some checks are pending
offline / test (push) Waiting to run
Some checks are pending
offline / test (push) Waiting to run
Paused or unhealthy replicas mark the service degraded even if the tree-node floor is still met. Unmanaged NATS with no process is down.
This commit is contained in:
parent
dd99ce1c64
commit
6fbc808bb1
4 changed files with 79 additions and 5 deletions
29
packages/verae-fleet/src/classify.js
Normal file
29
packages/verae-fleet/src/classify.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Row health: operational | degraded | down
|
||||
* @module classify
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* min?: number,
|
||||
* available?: number,
|
||||
* running?: number,
|
||||
* paused?: number,
|
||||
* managed?: boolean,
|
||||
* instances?: Array<{ pid?: number|null, paused?: boolean, healthy?: boolean }>
|
||||
* }} sv
|
||||
* @returns {'operational'|'degraded'|'down'}
|
||||
*/
|
||||
export function classifyService(sv) {
|
||||
const min = sv.min ?? 0;
|
||||
const available = sv.available ?? 0;
|
||||
const running = sv.running ?? 0;
|
||||
const paused = sv.paused ?? 0;
|
||||
const inst = sv.instances || [];
|
||||
const unhealthy = inst.filter((i) => i.pid && i.healthy === false && !i.paused).length;
|
||||
|
||||
if (min === 0 && running === 0) return 'operational';
|
||||
if (available === 0 && min > 0) return 'down';
|
||||
if (available >= min && paused === 0 && unhealthy === 0) return 'operational';
|
||||
return 'degraded';
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import path from 'node:path';
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { loadFleet } from './load.js';
|
||||
import { httpProbe, postControl } from './health.js';
|
||||
import { classifyService } from './classify.js';
|
||||
|
||||
const WORKER = path.join(path.dirname(fileURLToPath(import.meta.url)), 'worker.js');
|
||||
|
||||
|
|
@ -284,6 +285,7 @@ export class Supervisor {
|
|||
restarts: i.restarts,
|
||||
})),
|
||||
};
|
||||
services[spec.id].health = classifyService(services[spec.id]);
|
||||
}
|
||||
return {
|
||||
control: this.loaded.control,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue