fix(notifications): stop embedding Local in janitor alerts (#1631)

Fleet-aggregated reclaim alerts showed Node Local in the body while the
badge already named the remote. Use a node-neutral message so identity
comes from the hub badge; leave stored rows unchanged.
This commit is contained in:
Anso
2026-07-14 18:28:01 -04:00
committed by GitHub
parent c170c3f30c
commit 678c198faa
3 changed files with 9 additions and 7 deletions
@@ -1453,7 +1453,7 @@ describe('MonitorService - janitor cycle and circuit breaker', () => {
expect(mockGetDiskUsage).not.toHaveBeenCalled();
});
it('dispatches an alert when reclaimable exceeds the threshold', async () => {
it('dispatches a node-neutral janitor alert', async () => {
mockGetGlobalSettings.mockReturnValue({ docker_janitor_gb: '0.5' });
mockGetDiskUsage.mockResolvedValue(RECLAIMABLE_3GB);
mockGetSystemState.mockReturnValue('0'); // No prior alert; cooldown elapsed.
@@ -1462,7 +1462,10 @@ describe('MonitorService - janitor cycle and circuit breaker', () => {
await (svc as any).evaluateJanitor();
expect(mockDispatchAlert).toHaveBeenCalledWith(
'info', 'system', expect.stringContaining('3.0 GB'), { stackName: undefined, actor: 'system:monitor' },
'info',
'system',
'This node has accumulated 3.0 GB of unused Docker data. Open Resources to reclaim space, or set up a Prune Node Resources schedule.',
{ stackName: undefined, actor: 'system:monitor' },
);
});
+3 -4
View File
@@ -439,15 +439,14 @@ export class MonitorService {
const MIN_RECLAIMABLE_GB = 0.1;
if (reclaimGb >= janitorLimitGb && reclaimGb >= MIN_RECLAIMABLE_GB) {
const registry = NodeRegistry.getInstance();
const localNode = registry.getNode(registry.getDefaultNodeId());
const nodeLabel = localNode?.name ?? 'this node';
// Node-neutral body: the hub bell badge attributes remotes.
// Embedding the local seed name ("Local") made fleet alerts look wrong.
await this.dispatchWithCooldown(
HOST_ALERT_KEYS.janitor,
JANITOR_COOLDOWN_MS,
'info',
'system',
`Node "${nodeLabel}" has accumulated ${reclaimGb.toFixed(1)} GB of unused Docker data. Open Resources to reclaim space, or set up a Prune Node Resources schedule.`,
`This node has accumulated ${reclaimGb.toFixed(1)} GB of unused Docker data. Open Resources to reclaim space, or set up a Prune Node Resources schedule.`,
);
}
} finally {