From 2c733d3953da663577df5cfe929cf91c3ff39fd0 Mon Sep 17 00:00:00 2001 From: codex Date: Tue, 14 Jul 2026 15:55:22 -0300 Subject: [PATCH] scheduler: clear stale restic locks before backup --- internal/k8s/job_helpers_test.go | 2 +- internal/k8s/job_manifests.go | 2 +- internal/k8s/job_manifests_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/k8s/job_helpers_test.go b/internal/k8s/job_helpers_test.go index 306bbd5..20eafb3 100644 --- a/internal/k8s/job_helpers_test.go +++ b/internal/k8s/job_helpers_test.go @@ -82,7 +82,7 @@ func TestJobNameBackupCommandAndResticEnvCoverRemainingBranches(t *testing.T) { Dedupe: &dedupe, KeepLast: &keepLast, }) - if !strings.Contains(cmd, "restic init") || !strings.Contains(cmd, "--tag dedupe=off") || !strings.Contains(cmd, "--keep-last 3") { + if !strings.Contains(cmd, "restic unlock") || !strings.Contains(cmd, "restic init") || !strings.Contains(cmd, "--tag dedupe=off") || !strings.Contains(cmd, "--keep-last 3") { t.Fatalf("expected backup command to include bootstrap/dedupe/keep-last logic, got %q", cmd) } if !strings.Contains(cmd, "--exclude *.tmp") || !strings.Contains(cmd, "--tag nightly") || !strings.Contains(cmd, "--tag prod") { diff --git a/internal/k8s/job_manifests.go b/internal/k8s/job_manifests.go index 65d118d..e78a8f4 100644 --- a/internal/k8s/job_manifests.go +++ b/internal/k8s/job_manifests.go @@ -206,7 +206,7 @@ func backupCommand(cfg *config.Config, req api.BackupRequest) string { cmd = fmt.Sprintf("%s && %s", cmd, forget) } - bootstrap := "restic snapshots >/dev/null 2>&1 || restic init" + bootstrap := "restic unlock >/dev/null 2>&1 || true; restic snapshots >/dev/null 2>&1 || restic init" return "set -euo pipefail; " + bootstrap + "; " + cmd } diff --git a/internal/k8s/job_manifests_test.go b/internal/k8s/job_manifests_test.go index ff31b3c..7f175a6 100644 --- a/internal/k8s/job_manifests_test.go +++ b/internal/k8s/job_manifests_test.go @@ -49,7 +49,7 @@ func TestBuildBackupJobAppliesSelectorsServiceAccountAndMetadata(t *testing.T) { if container.Name != "restic" || container.Image != "restic/restic:latest" { t.Fatalf("expected restic container, got %#v", container) } - if len(container.Args) != 1 || !strings.Contains(container.Args[0], "restic backup /data") || !strings.Contains(container.Args[0], "--keep-last 3") { + if len(container.Args) != 1 || !strings.Contains(container.Args[0], "restic unlock") || !strings.Contains(container.Args[0], "restic backup /data") || !strings.Contains(container.Args[0], "--keep-last 3") { t.Fatalf("expected backup command payload, got %#v", container.Args) } if len(job.Spec.Template.Spec.Volumes) != 2 || job.Spec.Template.Spec.Volumes[0].PersistentVolumeClaim == nil {