From aa33c9f0361e262d78154d939ddde16647a83d2c Mon Sep 17 00:00:00 2001 From: lgtm <1gtm@users.noreply.github.com> Date: Sun, 12 Mar 2023 21:04:16 -0700 Subject: [PATCH] Prepare for release 4.0.5-v23 (#1752) ProductLine: Stash Release: v2023.03.13 Release-tracker: https://github.com/stashed/CHANGELOG/pull/63 Signed-off-by: 1gtm <1gtm@appscode.com> --- go.mod | 2 +- go.sum | 4 +-- vendor/modules.txt | 2 +- .../apimachinery/pkg/restic/commands.go | 26 +++++++++++-------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 0e08023dc..3ca0f854d 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( kmodules.xyz/custom-resources v0.25.0 kmodules.xyz/offshoot-api v0.25.0 kubedb.dev/apimachinery v0.28.4-0.20220918021210-a0b96812228b - stash.appscode.dev/apimachinery v0.26.0 + stash.appscode.dev/apimachinery v0.27.0 ) require ( diff --git a/go.sum b/go.sum index 9e71207cb..5f916eb54 100644 --- a/go.sum +++ b/go.sum @@ -908,5 +908,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kF sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -stash.appscode.dev/apimachinery v0.26.0 h1:74H87DYEMFUO6vesQARIaiXG9N6wSyakTzSoJhBRJZ0= -stash.appscode.dev/apimachinery v0.26.0/go.mod h1:SLknx4Og4nrUflEJIQF5gjolXmetqXrpisoDlFNV2DI= +stash.appscode.dev/apimachinery v0.27.0 h1:3Ldo0ncYnsRT4VukSrawan0jWjc+D/nss1yAyDjWj8A= +stash.appscode.dev/apimachinery v0.27.0/go.mod h1:0bPMB3d0+3oR2hBqFeZyskBDEO5CyWnkHNV+Gp67bMA= diff --git a/vendor/modules.txt b/vendor/modules.txt index 0399920ae..cef7f0438 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -668,7 +668,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.3.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# stash.appscode.dev/apimachinery v0.26.0 +# stash.appscode.dev/apimachinery v0.27.0 ## explicit; go 1.18 stash.appscode.dev/apimachinery/apis stash.appscode.dev/apimachinery/apis/repositories diff --git a/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go b/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go index 02bde12f6..591ce09c2 100644 --- a/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go +++ b/vendor/stash.appscode.dev/apimachinery/pkg/restic/commands.go @@ -149,12 +149,7 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) { klog.Infoln("Backing up stdin data") // first add StdinPipeCommands, then add restic command - var commands []Command - if len(options.StdinPipeCommands) != 0 { - for i := range options.StdinPipeCommands { - commands = append(commands, options.StdinPipeCommands[i]) - } - } + commands := options.StdinPipeCommands args := []interface{}{"backup", "--stdin", "--quiet", "--json"} if options.StdinFileName != "" { @@ -177,6 +172,19 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) { func (w *ResticWrapper) cleanup(retentionPolicy v1alpha1.RetentionPolicy, host string) ([]byte, error) { klog.Infoln("Cleaning old snapshots according to retention policy") + out, err := w.tryCleanup(retentionPolicy, host) + if err == nil || !strings.Contains(err.Error(), "unlock") { + return out, err + } + // repo is locked, so unlock first + klog.Warningln("repo found locked, so unlocking before pruning, err:", err.Error()) + if o2, e2 := w.unlock(); e2 != nil { + return o2, e2 + } + return w.tryCleanup(retentionPolicy, host) +} + +func (w *ResticWrapper) tryCleanup(retentionPolicy v1alpha1.RetentionPolicy, host string) ([]byte, error) { args := []interface{}{"forget", "--quiet", "--json"} if host != "" { @@ -304,11 +312,7 @@ func (w *ResticWrapper) dump(dumpOptions DumpOptions) ([]byte, error) { commands := []Command{ {Name: ResticCMD, Args: args}, } - if len(dumpOptions.StdoutPipeCommands) != 0 { - for i := range dumpOptions.StdoutPipeCommands { - commands = append(commands, dumpOptions.StdoutPipeCommands[i]) - } - } + commands = append(commands, dumpOptions.StdoutPipeCommands...) return w.run(commands...) }