fix(triage): gate image cluster_count on cluster liveness #18
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Motstandskraft/spam!18
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/triage-cluster-count-liveness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Triage's "X / Y clusters" count (
asset_risk.cluster_count) is computed in theasset_risk_srcview fromcluster_digests/publicly_exposed_digests, without thecluster_sessionsliveness gate that the image-detail Workloads tab (uiapi.ImageDetailHandler, viascam.LiveRecordFilter) applies.When a cluster's agent stops heartbeating (crash, network, decommission) no
DELETEevent arrives, so its pods staypod_phase='Running',msg<>'DELETE'. Triage keeps counting them; the Workloads tab correctly drops them. → count shows in triage but the Workloads tab is empty. For admins, the hidden-namespace and ACL filters are no-ops, so liveness is the sole divergence.This is the invariant
cluster_summaryalready documents: maintained tables can't bake aNOW()-relative gate, so the reader applies it — the triage path just never did.Fix
New migration
20260630a_asset_risk_live_cluster_spread.sql—CREATE OR REPLACE VIEW asset_risk_srcadding acluster_sessionslivenessEXISTSgate to the two image-spread CTEs (image_cluster_spread→cluster_count,image_exposed_spread→exposed_cluster_count, gated identically so "X/Y" stays consistent). Registered incmd/server/main.goafter20260630.Surgical scope: the existence JOIN and the cluster-type triage rows stay on raw
cluster_digests, so an image deployed only in a dead cluster still appears in triage (ranked by its other signals) withcluster_count = 0— the frontend hides the chip at 0, matching the empty Workloads tab. (Gatingcluster_digestsitself, which would also drop such images/dead-cluster rows from triage, is a possible follow-up.)The 24h window hardcodes
SPAM_CLUSTER_LIVE_WINDOW's default (Postgres can't read the env var); documented in the migration header. Takes effect on the nextasset_riskrebuild (~hourly debounce / daily backstop), bounding staleness like the existing bakedpod_phasegate.Verification
CREATE OR REPLACEin a rolled-back transaction against the lab DB → parses, column-compatible.go vet ./cmd/server/...clean,gofmtclean. No web changes.🤖 Generated with Claude Code