Skip to content

2026-10-25: Mattermost restore drill failed unpacking the file backup

Kind: reference (incident report)

Severity: warning · Status: resolved · Resolved by: operator agent · Duration: 0:35 from detection to resolution, 05:20–05:55 UTC (fault from 05:04) · Taskbase task: #1570, #1571

Summary

The weekly Mattermost restore drill (cnpg-drill/mattermost-restore-drill-29881740) restored the database but failed while unpacking the newest daily file backup. GNU tar tried to change the mode of the volume's root directory and was refused. This was the first time the drill had unpacked a real file archive, so the files half of Mattermost's backup has never been proven restorable, and the pre-upgrade gate's restore check would fail the same way. The fix to files.sh merged at 05:45, a manual drill on the fixed scripts passed at 05:54 with the file backup restored, and both alerts were clear by 05:55 (#1571).

Impact

  • Services: none. Mattermost itself was not touched. The weekly drill failed (KubeJobFailed, and CNPGRestoreDrillFailed once its 2h for passes). The gate's restore check (mattermost-preupgrade) uses the same step, so a stateful Mattermost upgrade would stop at its gate until the fix lands.
  • Users: none.
  • Data: none lost. The daily file backup hetzner-mgmt/mattermost/daily/20261025T040028Z downloaded and matched its checksum (files.tar: OK). From 10-21 (#1397) until the drill passed at 05:54, no file backup was proven restorable; the passing drill restored that same backup.
  • Duration: fault from 05:04 UTC (Job failed); alert from 05:20 UTC; resolved 05:55 UTC, when KubeJobFailed no longer fired and the drill had passed.

Timeline

All times UTC, 2026-10-25.

Time Event Source
05:00 CronJob mattermost-restore-drill starts Job mattermost-restore-drill-29881740 Job .status.startTime
~05:03 Database copy mattermost-drill restored, 8 users; files pod fetches 20261025T040028Z, checksum OK Job log
05:04 Container restore of pod mattermost-drill-files fails: tar: .: Cannot change mode to rwxrwxr-x: Operation not permitted; the drill's trap removes the throwaway Cluster, pod and volume Job log
05:04:39 Job Failed, BackoffLimitExceeded (backoffLimit 0) Job conditions
05:20 Detected: KubeJobFailed fires for job_name=mattermost-restore-drill-29881740 Alertmanager
05:21 Taskbase incident #1570 created; operator agent run starts Taskbase
05:22 Alertmanager confirms the alert is active, no silence api/v2/alerts, api/v2/silences
05:23 Failure reproduced locally with GNU tar 1.35; fix and regression test written this run
— Fix pull request opened for review (fix/1570-mattermost-files-restore-top-dir) Gitea
05:45 Fix pull request #743 merged (74b9671) Git
05:46–05:50 Flux rolls 74b9671 through the dependency chain; every Kustomization Ready, mattermost-backup-scripts in cnpg-drill carries --wildcards -xf /work/files.tar './?*' flux get kustomizations -A, ConfigMap
05:50 Follow-up #1571: manual drill Job mattermost-restore-drill-manual started kubectl create job
05:54 Drill passed: 8 users restored; files Files on disk: 2, at dump time: 2; Mattermost 11.1.1 smoke check OK; mattermost-drill lastSuccess 05:54:38 Job log, ConfigMap
05:55 Failed Job mattermost-restore-drill-29881740 deleted kubectl delete job
05:55 Resolved: Alertmanager has no KubeJobFailed or CNPGRestoreDrillFailed for cnpg-drill; Prometheus ALERTS{namespace="cnpg-drill"} empty api/v2/alerts, Prometheus

Root cause

files.sh dump archives the volume with tar -C /data ... ., so the archive's first member is ./, carrying the mode of the dumped /data (drwxrwsr-x). In the restore pod, /data is the root of a fresh hcloud volume: owned by root, group 2000 and setgid by fsGroup: 2000. files.sh restore ran tar -C /data --no-overwrite-dir -xf files.tar as uid 2000. GNU tar 1.35 (Debian trixie, image debian:13.7-slim) running as a non-root user drops the setgid bit on directories it extracts, and it does this even for an existing directory with --no-overwrite-dir. So it calls chmod(".", 0775). Only the owner (root) may do that, so the call fails with EPERM and tar exits 2.

Reproduced outside the cluster with GNU tar 1.35 as a non-root user into a root-owned setgid directory: --no-overwrite-dir and --no-same-permissions both fail the same way, and --exclude=. skips every member. Extracting the members that match ./?* (everything except ./) succeeds and leaves the directory's mode alone.

The --no-overwrite-dir came with the file volume in #1397 (2026-10-21). The only gate run since then (2026-10-21 06:53) restored "files none", and the drill had never recorded a pass (no ConfigMap cnpg-drill/mattermost-drill). This drill was the first run of the restore on a real archive.

What the agent did

Run of #1570, steps 1–8: every command was read-only, and no live write was made to the cluster.

  1. Alertmanager check: kubectl -n monitoring port-forward svc/alertmanager-operated 9093, then curl -sG http://localhost:9093/api/v2/alerts --data-urlencode 'filter=alertname="KubeJobFailed"': one alert, cnpg-drill mattermost-restore-drill-29881740, state active, silencedBy: []. api/v2/silences showed no active silence.
  2. flux get kustomizations -A --status-selector ready=false and flux get helmreleases -A --status-selector ready=false: nothing listed.
  3. kubectl -n cnpg-drill get all,cronjob,cluster.postgresql.cnpg.io, kubectl -n cnpg-drill logs mattermost-restore-drill-29881740-5qc6b, kubectl -n cnpg-drill get events: the root error is the tar error above. The cannot watch resource "persistentvolumeclaims" lines afterwards come from cleanup, and the deletes they follow succeeded.
  4. kubectl -n mattermost logs job/mattermost-preupgrade: the last gate run verified "files none", so it never unpacked an archive.
  5. kubectl -n cnpg-drill get pvc,pods,cluster.postgresql.cnpg.io: no leftovers from the drill.
  6. Reproduced the failure locally with GNU tar 1.35 and tested the alternatives (see Root cause). This followed the KubeJobFailed runbook (find why the Job failed) and the CNPGRestoreDrillFailed runbook, Mattermost (fix in components/mattermost/backup).
  7. Pull request on branch fix/1570-mattermost-files-restore-top-dir:
  8. scripts/files.sh restore extracts ./?*, which is every member except ./, and skips tar for a dump with no files.
  9. scripts/test_files.py gains tests that the restore leaves /data's mode (2775) alone and that a dump without files restores. The mode test fails on the old script (0755 != 2775), and all 16 component tests pass on the new one.
  10. The CNPGRestoreDrillFailed runbook names the files step and the files pod, and says to delete the failed Job once a manual run has passed.
  11. Did not delete the failed Job. By the ops runbook's CronJob-created Jobs, it is deleted only after a newer run succeeds. Deleting it now would clear KubeJobFailed while the backup is still unproven, so it waits for a passing drill (#1571).

Run of follow-up #1571, after #743 merged. Two live writes, both from the CNPGRestoreDrillFailed runbook, Mattermost and the ops runbook's CronJob-created Jobs:

  1. flux get kustomizations -A --status-selector ready=false at 05:46: 46 Kustomizations waiting on dependency ... revision is not up to date, all with conditions from the last 30 s. That was Flux rolling the just-merged 74b9671 down the dependency chain, not a failure. No write; polled until the list was empty at 05:50. flux get helmreleases -A --status-selector ready=false: nothing.
  2. kubectl -n cnpg-drill get configmap mattermost-backup-scripts -o jsonpath='{.data.files\.sh}' (and the same in mattermost): line 106 is tar -C /data --wildcards -xf /work/files.tar './?*', as in Git.
  3. Before the drill: Alertmanager showed KubeJobFailed active for mattermost-restore-drill-29881740 since 05:20, no silence; CNPGRestoreDrillFailed not firing (its 2h for had not passed). cnpg-drill had no drill leftovers.
  4. Write: kubectl -n cnpg-drill create job --from=cronjob/mattermost-restore-drill mattermost-restore-drill-manual (05:50:29), exit 0. The Job completed at 05:54:53; output under Resolution and verification.
  5. kubectl -n cnpg-drill get cronjob mattermost-restore-drill: lastSuccessfulTime 05:54:53, later than lastScheduleTime 05:00:00, so the CNPGRestoreDrillFailed expression no longer matches this CronJob.
  6. Write: kubectl -n cnpg-drill delete job mattermost-restore-drill-29881740 (05:55), exit 0, done only after the drill passed. Its log was checked first and still showed the tar error above.
  7. Alertmanager api/v2/alerts at 05:55: no KubeJobFailed or CNPGRestoreDrillFailed for cnpg-drill (only the unrelated KubeStatefulSetUpdateNotRolledOut for openbao, and Watchdog). Prometheus ALERTS{namespace="cnpg-drill"} and kube_job_failed{namespace="cnpg-drill",condition="true"} > 0: empty.
  8. This pull request: report set to resolved.

Resolution and verification

Resolved at 05:55 UTC. The fix passes the component tests (run of #1570). On the cluster, the manual drill on the merged scripts printed:

Restoring mattermost latest (ghcr.io/cloudnative-pg/postgresql:18.1-system-trixie) into cnpg-drill/mattermost-drill
Restored users: 8
[pod/mattermost-drill-files/fetch] Fetching hetzner-mgmt/mattermost/daily/20261025T040028Z
[pod/mattermost-drill-files/fetch] files.tar: OK
[pod/mattermost-drill-files/restore] Files on disk: 2, at dump time: 2
[pod/mattermost-drill-mattermost/smoke] Mattermost reports version 11.1.1, status OK: smoke check passed
Drill passed.

kubectl -n cnpg-drill get configmap mattermost-drill -o jsonpath='{.data}' shows lastSuccess 2026-10-25T05:54:38Z, pod mattermost-restore-drill-manual-rrq92, version 11.1.1: this is the drill's first recorded pass. The failed Job is gone, and neither alert fires (step 15).

Follow-ups

  • 1571: re-run the Mattermost restore drill on the fixed scripts, delete mattermost-restore-drill-29881740, confirm KubeJobFailed and CNPGRestoreDrillFailed resolve, and mark this report resolved. Done (this pull request).

References

Open questions

  • The drill's and the gate's ServiceAccounts may not watch PersistentVolumeClaims in cnpg-drill, so kubectl delete --wait logs Failed to watch errors, although the deletes succeed. Whether to grant watch is an access decision left to the owner. It did not cause this failure.
  • cnpg-drill still holds a ConfigMap drill-mattermost (lastSuccess 2026-10-21, database only). It is not in Git: the database-only drill CronJob drill-mattermost that wrote it has since been replaced by mattermost-restore-drill, which writes mattermost-drill. It was removed on 2026-11-15 (task #3230), together with the equally orphaned drill-keycloak (replaced by keycloak-drill).