Preserve health during empty-server monitoring handoff (Refs #148)
This commit is contained in:
@@ -132,8 +132,22 @@ export async function observeRun(run: TestRun, plan: BetaPlan): Promise<void> {
|
||||
const m = readMetrics(run);
|
||||
const row = getServer(run.server);
|
||||
const server = row ? serverObservation(row) : null;
|
||||
const timestamp =
|
||||
let timestamp =
|
||||
server?.status_source === 'telemetry' ? server.last_seen_at : server?.last_checked_at;
|
||||
let source = server?.status_source;
|
||||
// Telemetry owns the displayed roster until it expires, but a newer
|
||||
// successful RCON reply is already health evidence during the handoff.
|
||||
const rconSeen = server?.rcon_status?.last_seen_at;
|
||||
if (
|
||||
server?.health === 'online' &&
|
||||
server.status_source === 'telemetry' &&
|
||||
rconSeen &&
|
||||
Date.parse(rconSeen) > Date.parse(timestamp ?? '') &&
|
||||
Date.parse(rconSeen) <= Date.now()
|
||||
) {
|
||||
timestamp = rconSeen;
|
||||
source = 'rcon';
|
||||
}
|
||||
const sample = Date.parse(timestamp ?? '');
|
||||
const freshSample =
|
||||
Number.isFinite(sample) &&
|
||||
@@ -149,7 +163,7 @@ export async function observeRun(run: TestRun, plan: BetaPlan): Promise<void> {
|
||||
evidence(run, `sample:${sample}`, 'status-sample', {
|
||||
healthy,
|
||||
checkedAt: timestamp,
|
||||
source: server?.status_source
|
||||
source
|
||||
});
|
||||
if (before !== m.wasHealthy)
|
||||
evidence(run, `health:${at}`, 'health', { healthy, reason: server?.last_error ?? null });
|
||||
|
||||
Reference in New Issue
Block a user