Skip to content

Commit

Permalink
Updated compact subcommend to throw warning instead of error if revis…
Browse files Browse the repository at this point in the history
…ions are already compacted
  • Loading branch information
aaronfern authored and shreyas-s-rao committed Jul 15, 2021
1 parent 8edc335 commit cfae9a6
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 cfae9a6

Please sign in to comment.