Skip to content

2026-11-04: GitHub push mirror run failed on a 401 while Gitea's database was down

Kind: reference (incident report)

Severity: warning · Status: resolved · Resolved by: operator agent · Duration: 0:55 from detection to resolution, 17:45–18:40 UTC (fault from 17:30 UTC) · Taskbase task: #2500

Summary

During the worker-3 stall of the same afternoon, Gitea kept running but could not reach its database. The push mirror CronJob's 17:30 run, gitea/github-push-mirror-29896890, called Gitea four seconds before the database was back. Gitea could not look up the token and answered 401 Unauthorized, so the Job failed. The next runs succeeded, but the failed Job stayed and kept KubeJobFailed firing until the operator deleted it.

Impact

  • Services: one run of the push mirror reconciler (components/gitea/push-mirror) failed. The GitHub push mirror itself was not affected: the runs from 17:45 on found it healthy, last updated at 18:27:14.
  • Users: none noticed; the alert is a warning.
  • Data: none.
  • Duration: the Job failed at 17:30:05. KubeJobFailed fired from 17:45:33 and was resolved at 18:40:25, when Prometheus had no kube_job_failed series for the Job and Alertmanager had no KubeJobFailed alert.

Timeline

All times UTC, 2026-11-04.

Time Event Source
17:17:17 Gitea logs its first database error; worker-3, which runs gitea-postgresql-0, has stopped answering (#2490) worker-3 report
17:22:57 gitea-postgresql-0 is recreated on worker-1 and waits for its volume pod creationTimestamp
17:29:59 gitea-postgresql-0 container started pod containerStatuses
17:30:00 CronJob creates github-push-mirror-29896890 (pod on worker-3) Job annotation cronjob-scheduled-timestamp
17:30:01–02 Gitea: userFromToken: dial tcp 10.111.180.68:5432: connect: connection refused, then GET /api/v1/repos/Skatzi/platform/push_mirrors?limit=50 … 401 Unauthorized Gitea log
17:30:02 Job pod exits 1 with urllib.error.HTTPError: HTTP Error 401: Unauthorized pod log, containerStatuses
17:30:05 Job fails: BackoffLimitExceeded (backoffLimit: 0) Job status.conditions
17:30:06 Gitea's last database error, connection refused Gitea log
17:30:09 gitea-postgresql-0 Ready pod conditions
17:45:02 Next run's GET …/push_mirrors answers 200 OK; also at 18:00:05, 18:15:02 and 18:30:02 Gitea log
17:45:33 Detected: KubeJobFailed (job_name=github-push-mirror-29896890, fingerprint a14ffa663ecb3f23) starts firing Alertmanager
17:46:34 Taskbase incident #2500 created Taskbase
~18:38 operator agent confirms the alert is active and not silenced, and finds the cause (What the agent did) this report
18:39:41 Operator deletes the failed Job kubectl delete job
18:40:25 Resolved: no kube_job_failed series for the Job, and Alertmanager has no KubeJobFailed alert Prometheus and Alertmanager API

Root cause

When worker-3 stalled (#2490), the taint manager evicted gitea-postgresql-0. Its replacement on worker-1 waited for the Hetzner volume until 17:29:32 and was Ready at 17:30:09. Gitea itself ran on worker-2 the whole time, so its Service had a backend, but every request that needs the database failed. For a token request that failure is a 401. Gitea's OAuth2.Verify cannot read the token (userFromToken: … connection refused), and apiAuth treats the request as unauthenticated.

The push mirror reconciler (components/gitea/push-mirror/reconcile-push-mirror.py) already waits up to GITEA_WAIT_SECONDS while Gitea cannot be reached, a retry added after the 2026-10-25 incident (#1591). That retry covers only URLError, a connection that fails. An HTTPError is re-raised at once, so that a wrong token fails the run. A database outage behind a running Gitea looks like a wrong token, and the run failed on its first call (backoffLimit: 0).

The CronJob keeps failed Jobs (failedJobsHistoryLimit: 3, ttlSecondsAfterFinished: 86400), and a later success does not remove them, so KubeJobFailed would have fired for up to 24 hours. The window comes back whenever Gitea's database is down while Gitea is up, for example a worker stall like #2490 or a PostgreSQL restart. #2507 makes the reconciler wait through it.

What the agent did

The agent followed the ops runbook section KubeJobFailed for a Job that Flux applies, case CronJob-created Jobs, "a one-off window that is already over".

  1. kubectl -n monitoring port-forward svc/alertmanager-operated 19093:9093, then curl -sG .../api/v2/alerts --data-urlencode 'filter=alertname="KubeJobFailed"': one alert, active, for gitea/github-push-mirror-29896890, with no silencedBy or inhibitedBy. /api/v2/silences had no active silence.
  2. kubectl -n gitea get jobs,cronjobs and describe job: the Job is Failed 0/1 and is owned by CronJob/github-push-mirror. The 18:30 run github-push-mirror-29896950 is Complete 1/1.
  3. kubectl -n gitea logs github-push-mirror-29896890-nlmqn: the first GET /push_mirrors failed with HTTPError: HTTP Error 401: Unauthorized. The Job's status.conditions show BackoffLimitExceeded at 17:30:05.
  4. kubectl -n gitea get externalsecret: github-mirror-token is SecretSynced, and the Secret was last written on 2026-10-21, so the token had not changed. Later runs with the same token succeeded.
  5. kubectl -n gitea logs gitea-645cd4459d-dnjb7 --since-time=…: database connection refused errors from 17:17:34 to 17:30:06 (the first database error, an i/o timeout at 17:17:17, is in the worker-3 report), and at 17:30:01–02 userFromToken: … connection refused followed by the 401 for the Job's request. kubectl -n gitea get pod gitea-postgresql-0: created 17:22:57, started 17:29:59, Ready 17:30:09. The cause is the #2490 database outage, which was over.
  6. kubectl -n gitea get cronjob github-push-mirror: lastSuccessfulTime 18:30:05, later than the failure. Gitea's log shows 200 OK for push_mirrors at 17:45, 18:00, 18:15 and 18:30, and the 18:30 run logs "push mirror … is healthy, last update 2026-11-04T18:27:14Z". flux get kustomizations -A and flux get helmreleases -A with --status-selector ready=false listed nothing, and https://gitea.prod.skatzi.com/api/healthz returned 200.
  7. Write: kubectl -n gitea delete job github-push-mirror-29896890 at 18:39:41. Exit 0. The Job and its Error pod are gone, and the Job mounted only its script ConfigMap, so it held no data.
  8. Polled Prometheus (kube_job_failed{namespace="gitea",job_name="github-push-mirror-29896890"} > 0) and Alertmanager every 30 s: no series and no KubeJobFailed alert at 18:40:25.
  9. Created follow-up #2507 and opened this report's pull request.

No Git change was needed to fix the cause, no Kustomization or HelmRelease was suspended or reconciled, and no silence was set.

Resolution and verification

  • Alertmanager: /api/v2/alerts?filter=alertname="KubeJobFailed" returns [], and there is no GiteaPushMirrorFailing alert. The only active alert is Watchdog.
  • Prometheus: kube_job_failed{namespace="gitea",job_name="github-push-mirror-29896890"} > 0 returns no series.
  • flux get kustomizations -A --status-selector ready=false and flux get helmreleases -A --status-selector ready=false list nothing.
  • helm -n gitea history gitea: revision 7 is deployed, chart gitea-12.7.0. deployment/gitea and statefulset/gitea-postgresql are 1/1 Ready.

Follow-ups

  • 2507 — when the first API call gets a 401 or 5xx and Gitea's /api/healthz is not healthy, retry it

    within GITEA_WAIT_SECONDS; a wrong token with a healthy Gitea still fails the run.
  • 2498 (from #2490) — the act runner memory overcommit that stalled worker-3.

  • 2540 — not part of this incident: at 18:42:48, after this one was resolved, seven pod sandboxes on

    worker-2 were killed and recreated. Gitea answered 503 until 18:44:46, and Flux was Ready again at 18:47:53. The agent saw this while checking the state after its fix and changed nothing. #2540's report points to Talos's OOM controller, during an agent run; that is not confirmed until #2546 reads the node's logs.

References

Open questions

none