Skip to content

CNPGRestoreDrillFailed

Severity: critical. Fires when, for 2 hours, the last scheduled run of a restore drill CronJob in cnpg-drill has not succeeded, a drill has never succeeded, or none has succeeded in 8 days. The weekly drill restores the latest backup of a CloudNativePG Cluster into a throwaway Cluster and checks the data, so this alert means the backup of that database is not proven restorable. Stateful upgrades of the database must wait (ops runbook).

Labels: namespace (cnpg-drill), cronjob (drill-<serverName>, e.g. drill-terraform-state, which names the database; Mattermost's drill is named differently, see below). Component: cloudnative-pg. How the drill works: CloudNativePG.

Read-only checks

# Last schedule and last success of every drill
kubectl --context <context> -n cnpg-drill get cronjob

# The failed Job and its log (the log shows the Cluster manifest the drill used)
kubectl --context <context> -n cnpg-drill get jobs
kubectl --context <context> -n cnpg-drill logs job/<job>

# A throwaway Cluster left behind, and its pods
kubectl --context <context> -n cnpg-drill get clusters.postgresql.cnpg.io,pods

# The last recorded success
kubectl --context <context> -n cnpg-drill get configmap drill-<serverName> -o jsonpath='{.data}'

# Is the backup itself fine? See also the two sibling alerts
kubectl --context <context> -n <database namespace> get backups.postgresql.cnpg.io

Usual causes: no base backup in the store yet or CNPGBackupStale / CNPGWALArchivingFailing firing for the same database, the backup-store Secret or ObjectStore missing in the database namespace, the drill query returning no rows, or the one-hour deadline hit while the restore was still replaying WAL.

Roll forward

Fix the cause in Git (ObjectStore, Secret, drill query in cluster/hetzner-mgmt/cloudnative-pg/drill/cron-job.yaml; for Mattermost see below) in a pull request. Then run the drill now instead of waiting for Sunday:

kubectl --context <context> -n cnpg-drill create job --from=cronjob/drill-<serverName> drill-<serverName>-manual
kubectl --context <context> -n cnpg-drill logs -f job/drill-<serverName>-manual

The alert clears (after up to its 2h for) once kubectl --context <context> -n cnpg-drill get cronjob shows LAST SUCCESSFUL later than LAST SCHEDULE; a manual run counts. Delete a leftover throwaway Cluster drill-<serverName> in cnpg-drill only; never touch the production Cluster.

Mattermost

Mattermost's drill does not follow the drill-<serverName> pattern: it also starts Mattermost on the restored copy and runs the smoke check (Mattermost: weekly restore drill).

  • CronJob: mattermost-restore-drill (cronjob label of the alert).
  • Record of the last success: ConfigMap cnpg-drill/mattermost-drill.
  • Leftovers to delete in cnpg-drill only: Cluster mattermost-drill and pods mattermost-drill-files and mattermost-drill-mattermost.
  • Fixes go in components/mattermost/backup (scripts/drill.sh, scripts/lib.sh, templates/restore-pod.yaml, cron-job.yaml; the newest file backup is unpacked by scripts/files.sh restore in templates/files-restore-pod.yaml), not in cluster/hetzner-mgmt/cloudnative-pg/drill/cron-job.yaml. Its Job has a 3-hour deadline.
  • The failed Job stays, and KubeJobFailed for it keeps firing, until it is deleted: delete it (kubectl --context <context> -n cnpg-drill delete job <job>) once a manual run has passed.
kubectl --context <context> -n cnpg-drill create job --from=cronjob/mattermost-restore-drill mattermost-restore-drill-manual
kubectl --context <context> -n cnpg-drill logs -f job/mattermost-restore-drill-manual

Roll back

If the drill broke with a CloudNativePG, Barman Cloud plugin or drill-image change, revert that version bump in a pull request, as in the generic Flux freeze roll-back, after the CRD checks of the pre-flight. To prove a restore by hand, follow Restoring by hand into a new Cluster.