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, andCNPGRestoreDrillFailedonce its 2hforpasses). 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/20261025T040028Zdownloaded 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
KubeJobFailedno 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.
- Alertmanager check:
kubectl -n monitoring port-forward svc/alertmanager-operated 9093, thencurl -sG http://localhost:9093/api/v2/alerts --data-urlencode 'filter=alertname="KubeJobFailed"': one alert,cnpg-drill mattermost-restore-drill-29881740, stateactive,silencedBy: [].api/v2/silencesshowed no active silence. flux get kustomizations -A --status-selector ready=falseandflux get helmreleases -A --status-selector ready=false: nothing listed.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. Thecannot watch resource "persistentvolumeclaims"lines afterwards come from cleanup, and the deletes they follow succeeded.kubectl -n mattermost logs job/mattermost-preupgrade: the last gate run verified "files none", so it never unpacked an archive.kubectl -n cnpg-drill get pvc,pods,cluster.postgresql.cnpg.io: no leftovers from the drill.- 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). - Pull request on branch
fix/1570-mattermost-files-restore-top-dir: scripts/files.sh restoreextracts./?*, which is every member except./, and skips tar for a dump with no files.scripts/test_files.pygains 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.- The CNPGRestoreDrillFailed runbook names the files step and the files pod, and says to delete the failed Job once a manual run has passed.
- 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
KubeJobFailedwhile 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:
flux get kustomizations -A --status-selector ready=falseat 05:46: 46 Kustomizations waiting ondependency ... revision is not up to date, all with conditions from the last 30 s. That was Flux rolling the just-merged74b9671down 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.kubectl -n cnpg-drill get configmap mattermost-backup-scripts -o jsonpath='{.data.files\.sh}'(and the same inmattermost): line 106 istar -C /data --wildcards -xf /work/files.tar './?*', as in Git.- Before the drill: Alertmanager showed
KubeJobFailedactive formattermost-restore-drill-29881740since 05:20, no silence;CNPGRestoreDrillFailednot firing (its 2hforhad not passed).cnpg-drillhad no drill leftovers. - 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. kubectl -n cnpg-drill get cronjob mattermost-restore-drill:lastSuccessfulTime05:54:53, later thanlastScheduleTime05:00:00, so theCNPGRestoreDrillFailedexpression no longer matches this CronJob.- 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. - Alertmanager
api/v2/alertsat 05:55: noKubeJobFailedorCNPGRestoreDrillFailedforcnpg-drill(only the unrelatedKubeStatefulSetUpdateNotRolledOutforopenbao, andWatchdog). PrometheusALERTS{namespace="cnpg-drill"}andkube_job_failed{namespace="cnpg-drill",condition="true"} > 0: empty. - 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, confirmKubeJobFailedandCNPGRestoreDrillFailedresolve, and mark this report resolved. Done (this pull request).¶
References¶
- Alert:
KubeJobFailed(runbook); related: CNPGRestoreDrillFailed - Taskbase incident task: #1570
- Runs: the
operatorruns of #1570 and #1571 - Pull requests: #743 (fix and this report), and the pull request for #1571 that marks it resolved
- Runbook sections: Ops runbook: CronJob-created Jobs, CNPGRestoreDrillFailed: Mattermost, Mattermost backup
Open questions¶
- The drill's and the gate's ServiceAccounts may not
watchPersistentVolumeClaims incnpg-drill, sokubectl delete --waitlogsFailed to watcherrors, although the deletes succeed. Whether to grantwatchis an access decision left to the owner. It did not cause this failure. cnpg-drillstill holds a ConfigMapdrill-mattermost(lastSuccess2026-10-21, database only). It is not in Git: the database-only drill CronJobdrill-mattermostthat wrote it has since been replaced bymattermost-restore-drill, which writesmattermost-drill. It was removed on 2026-11-15 (task #3230), together with the equally orphaneddrill-keycloak(replaced bykeycloak-drill).