mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 04:33:36 +09:00
ScaleStuck and ScaleBlocked joined on namespace alone, assuming one autoscaled database per namespace — but a tenant may run several Postgres apps in one namespace. A Pending pod of one CNPG cluster then falsely tripped a healthy sibling's ScaleStuck, and ScaleBlocked's namespace-wide pod count masked a real block on one cluster. Derive a `cluster` label from the keda-hpa-<cluster> HPA name with label_replace and join the pod terms on (namespace, cluster). ScaleBlocked also cried wolf on a healthy multi-step scale-up of a single large database: CNPG materialises replicas one basebackup at a time (each often >15m), so the instance count legitimately lags a desired jump of +2 with no Pending pod, and the old rule fired with the actively-harmful "lower maxReplicas" advice. Count only instance pods (a transient join Job pod otherwise inflates the count and masks a block) and suppress via `unless` while a join Job is provisioning a replica; a genuine admission block creates neither. Make the desired > current comparison an explicit on(namespace,horizontalpodautoscaler) join. Note in the egress NetworkPolicy values that its `cluster` entity does not restrict cross-namespace egress (the chart's namespace-pin does) and that off-cluster / link-local IMDS denial depends on CNI enforcement. Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>