feat(secrets-manager-gke): Alert on OpenBao active node count and HA lock loss
Note
core_active in production: after a failover, the new active node reported core_active = 0 for 24 hours, because the cluster label on its metrics changed and a stale series collided with the current one. https://gitlab.com/gitlab-org/govern/secrets-management/secrets-manager-runway/-/merge_requests/38 fixes it by setting cluster_name, and is deployed. It still needs confirming at the next failover; see https://gitlab.com/gitlab-org/gitlab/-/work_items/637006.
Important
Builds on !12004 (merged), which creates the same Jsonnet file for the paging alerts. This MR targets its branch until it merges, so the diff only shows this MR's changes.
What does this MR do?
Adds two alerts for the secrets-manager-gke service (OpenBao on Runway):
SecretsManagerGkeActiveNodeCountNotOnefires when an environment doesn't have exactly one active OpenBao node for 5 minutes.SecretsManagerGkeLeadershipLostfires when an OpenBao node loses the PostgreSQL HA lock and steps down.
Related to gitlab-org/gitlab#611251, which gitlab-org/gitlab#635679 (closed) was closed as a duplicate of. That one is a corrective action for https://gitlab.com/gitlab-com/gl-infra/production/-/work_items/23296. This MR covers the item "Consider a paging alert for no active OpenBao pod", except paging: both alerts start at s3 so they don't page, and move to s2 once we've confirmed they don't fire falsely.
The existing secrets-manager-gke alerts come from Runway load-balancer metrics only, so nothing checks that one node holds the PostgreSQL HA lock. Zero active nodes means requests can't be served, and more than one means leadership is churning. The runbook already describes this check in Is a node active or on standby?, based on core_active.
How it works
sum by (env, environment) (
max by (env, environment, pod) (last_over_time(secrets_manager_gke_core_active{}[2m]))
) > 1
or
sum by (env, environment) (
max by (env, environment, pod) (secrets_manager_gke_core_active{})
) < 1
or
(
sum by (env, environment) (kube_deployment_spec_replicas:labeled{type="secrets-manager-gke"}) > 0
unless on (env, environment)
sum by (env, environment) (secrets_manager_gke_core_active{})
) * 0- The first two clauses count active pods per environment.
max by (pod)collapses the duplicate series a collector upgrade gives one pod for a few minutes, so they don't read as two active nodes. - More than one active node only counts samples from the last 2 minutes. Mimir on Runway writes no staleness markers, so after a failover the old active pod's last
1stays visible for 5 minutes next to the new active pod's. Pods are scraped every 30 seconds, so 2 minutes still tolerates up to three missed scrapes. - No active node keeps the 5-minute lookback. With
Recreate, a rollout leaves no active node for about 6 minutes, and the lingering1is what keeps it under thefor. - The third clause catches an environment whose deployment wants replicas but where no pod reports
core_active, for example when every pod is down. The first two clauses can't see that case.* 0makes the alert report 0 active nodes. It keeps firing for as long as the outage lasts. A gap in the metrics pipeline drops the kube-state metrics too, so it stays quiet then. - All clauses have the same labels, so a crash loop that flips between
0and no data stays in one pending alert. for: 5mkeeps deploys quiet. The three production rollouts since 2026-11-03 left the count away from 1 for 1.5 to 2.5 minutes, but that was measured through the same 5-minute lookback, so the margin is thinner than it looks.
Replayed with the 5-minute for on mimir-runway, from 2026-11-03 to 2026-11-16, before the 2-minute window for more than one active node:
| Date (UTC) | What happened | offset 1h (previous) |
absent() per env |
Replica gate (this MR) |
|---|---|---|---|---|
| 2026-11-03, staging | Metrics gap, OpenBao fine | fires | fires | quiet |
| 2026-11-05, production | Collector upgrade, two series for one pod | quiet, 75 seconds short | quiet | quiet |
| 2026-11-06, both | Metrics gap, OpenBao fine | fires | fires | quiet |
| 2026-11-12, staging | No pod available for over two hours | fires, resolves after an hour | fires throughout | fires throughout |
The 2026-11-05 row uses the per-pod max for the last two columns. The current expression, replayed from 2026-11-03 to 2026-11-17, never fires in production, including the 2026-11-17 failover, and fires in staging only during the 2026-11-12 outage.
SecretsManagerGkeLeadershipLost
A lost HA lock leaves no active node only until the standby finishes post-unseal, usually 2 to 3 minutes. That's shorter than the 5-minute for above, so SecretsManagerGkeActiveNodeCountNotOne doesn't fire. Shortening that for would fire on every deploy instead, since a rollout also leaves no active node for several minutes. This alert counts the step-downs themselves, from core_leadership_lost:
sum by (env, environment) (
max by (env, environment, pod) (secrets_manager_gke_core_leadership_lost_count{})
- (
(
max by (env, environment, pod) (
last_over_time(secrets_manager_gke_core_leadership_lost_count{}[1h] offset 10m)
)
<=
max by (env, environment, pod) (secrets_manager_gke_core_leadership_lost_count{})
)
or
(
max by (env, environment, pod) (secrets_manager_gke_core_leadership_lost_count{}) * 0
and on (env, environment, pod)
max by (env, environment, pod) (
last_over_time(secrets_manager_gke_core_active{}[1h] offset 10m)
)
)
)
) > 0- The summary's series is created by its first event, already counting 1, so
increase()can't see a node's first lock loss. The offset baseline, withor ... * 0for a series that didn't exist 10 minutes ago, can. This is the patternArtifactRegistryManifestPayloadCopyFaultuses. last_over_time(...[1h])keeps a short scrape gap from looking like a new series.- The baseline is dropped when it's above the current count, as when the container restarts in place and the counter starts again. The count is then compared with 0. Without this, the next lock loss stayed hidden for up to 70 minutes. The difference can't go negative, so the expression needs no
clamp_min. - Comparing with 0 only applies to a pod that reported
core_activein the same window. Otherwise, after a scrape gap or a data loss longer than the window, the alert would count the pod's whole history. The cost: a new pod's first step-down in its first 10 minutes doesn't fire, which only happens after a rollout or a node drain. max by (pod)on both sides keeps a pod's relabelled series, as after a collector upgrade, from getting a baseline of 0 and firing for a lock loss already reported. Replayed onmimir-runwayfrom 2026-10-24 to 2026-11-16, it fires on the same two lock losses as before: 2026-10-29 and 2026-11-02.
OpenBao also records leadership_lost when the active node shuts down (ha.go), so a deploy could look like a lock loss. Two production rollouts in Mimir show it doesn't:
- 2026-11-03: the old active pod's existing series stayed at 1 until its last point, more than a minute after shutdown started.
- 2026-11-05: no series appeared for the old active pod.
Routing
The alert carries feature_category: secrets_management, so it reaches #sec-secrets-manager-alerts through the feature-category route, as decided in #235 (closed). The team route only matches env="gprd", while Runway sets env="production". That's also why that route never delivered for this service. The team: secrets_manager_openbao label stays as an ownership label.
Severity is s3 with no pager, so it only goes to Slack. Staging alerts land in #alerts instead of the team channel, like the staging copies of the paging alerts in !12005 (merged).
Both alerts link the secrets-manager-gke overview dashboard for their environment, like the generated SLO alerts, and the runbook lists them under Alerts.
Files
libsonnet/alerts/secrets-manager-gke-alerts.libsonnet: the alert rules, added after the paging alerts from !12004 (merged).mimir-rules/runway/secrets-manager-gke/autogenerated-…-secrets-manager-gke-alerts.yml: generated bymake generate.test/mimir-rules/secrets-manager-gke-alerts_test.yml:promtoolunit tests for both alerts, after the tests from !12004 (merged).docs/secrets-manager-gke/README.md: the two alerts in the Alerts list, after the paging alerts.
Verification
-
make generateproduces no diff beyond these files. -
mimirtool rules checkandjsonnetfmt --testpass. -
promtool test rules test/mimir-rules/secrets-manager-gke-alerts_test.ymlpasses: the alert fires on a node's first and second lock loss, including after the container restarts in place, and stays silent across a 7-minute scrape gap, including where a plainoffset 10mwould find no baseline, a scrape gap longer than the baseline window, when the series expires, and when a pod's series is relabelled at the same count. With a plainincrease()instead, the first-loss test fails. With a plainoffset 10minstead oflast_over_time(...[1h] offset 10m), the 7-minute gap test fails. Against the previous expression, the restart and long-gap tests fail.SecretsManagerGkeActiveNodeCountNotOnefires on two active pods, when every pod reports 0, and while every pod is gone, including more than an hour later. It stays silent on one pod with two series, on a failover where the old pod's last sample lingers, and on a metrics pipeline gap. Against the previous expressions, the duplicate-series, outage and failover cases fail. Without the< 1clause, the all-zero case fails. - Replay both versions of the active-node expression on
mimir-runwayfrom 2026-11-03 to 2026-11-16, as in the table above, and the current one until 2026-11-17. - Replay the current
SecretsManagerGkeLeadershipLostexpression onmimir-runwaysince 2026-10-24: it should fire on the same two lock losses. - Check in Mimir that the 2026-11-03 and 2026-11-05 rollouts didn't increase
secrets_manager_gke_core_leadership_lost_countor create a new series. - Confirm the metric carries
envandenvironmentlabels: runsum by (env, environment, pod) (secrets_manager_gke_core_active)in Grafana Explore on themimir-runwaydatasource.
A dashboard panel for this metric will come in a separate MR.