Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated compact subcommand to throw warning instead of error if revisions are already compacted #358

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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