From cfae9a67fdcd07744d4cd55928a106719b0463f8 Mon Sep 17 00:00:00 2001 From: aaronfern Date: Mon, 5 Jul 2021 20:39:15 +0530 Subject: [PATCH] Updated compact subcommend to throw warning instead of error if revisions are already compacted --- cmd/compact.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/compact.go b/cmd/compact.go index 609eca793..e8af43e6d 100644 --- a/cmd/compact.go +++ b/cmd/compact.go @@ -16,10 +16,12 @@ package cmd import ( "context" + "strings" "github.com/gardener/etcd-backup-restore/pkg/compactor" "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "go.etcd.io/etcd/mvcc" ) // NewCompactCommand compacts the ETCD instance @@ -47,7 +49,11 @@ func NewCompactCommand(ctx context.Context) *cobra.Command { cp := compactor.NewCompactor(store, logrus.NewEntry(logger)) snapshot, err := cp.Compact(options, opts.needDefragmentation) if err != nil { - logger.Fatalf("Failed to restore snapshot: %v", err) + if strings.Contains(err.Error(), mvcc.ErrCompacted.Error()) { + logger.Warnf("Stopping backup compaction: %v", err) + } else { + logger.Fatalf("Failed to compact snapshot: %v", err) + } return } logger.Infof("Compacted snapshot name : %v", snapshot.SnapName)