scheduler: clear stale restic locks before backup
This commit is contained in:
parent
ad0109305a
commit
2c733d3953
@ -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") {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user