Skip to content

Commit

Permalink
Merge pull request #358 from shreyas-s-rao/fix/compact-error-handling
Browse files Browse the repository at this point in the history
Updated compact subcommand to throw warning instead of error if revisions are already compacted
  • Loading branch information
abdasgupta committed Jul 15, 2021
2 parents 8edc335 + cfae9a6 commit 8bfb6c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8bfb6c3

Please sign in to comment.