feat(health-check): introduce health probe gap configuration and enhance health check logic
Build and Push CFDM Docker Image / build-and-push (push) Successful in 2m0s
Build and Push CFDM Docker Image / create-release (push) Skipped
Build and Push CFDM Docker Image / update-wiki (push) Successful in 6s

Added `healthProbeGapMs` configuration to control the minimum pause between probes to different physical targets. Updated health check service to utilize this configuration, ensuring efficient probing without overwhelming the targets. Enhanced the `runAllChecks` function to group probes by physical IP and implement the new gap logic. Updated related tests to validate the new functionality.
This commit is contained in:
Denozordec committed 2026-07-20 03:57:37 +07:00
1 parent a58d91ff5e
commit 9783974949
8 files changed
+270 -66

No files matched your search

+32
View File
@@ -1687,6 +1687,38 @@ export function deleteIpHealthStatusForIp(
.run();
}
/** Drop health rows whose IP is no longer a live probe target for that scope/ref. */
export function pruneStaleIpHealthStatus(
db: Db,
activeTargets: Array<{ scope: HealthCheckScope; ref_id: number; ip: string }>,
): number {
const byRef = new Map<string, Set<string>>();
for (const t of activeTargets) {
const key = `${t.scope}:${t.ref_id}`;
let ips = byRef.get(key);
if (!ips) {
ips = new Set();
byRef.set(key, ips);
}
ips.add(t.ip);
}
let deleted = 0;
for (const [key, ips] of byRef) {
const sep = key.indexOf(":");
const scope = key.slice(0, sep) as HealthCheckScope;
const refId = Number(key.slice(sep + 1));
if (!Number.isFinite(refId)) continue;
for (const row of listIpHealthStatus(db, scope, refId)) {
if (!ips.has(row.ip)) {
deleteIpHealthStatusForIp(db, scope, refId, row.ip);
deleted += 1;
}
}
}
return deleted;
}
// --- Health Check Targets ---
export function listHealthCheckTargets(db: Db): HealthCheckTarget[] {