From 254b52077ee7f545b8665c31c8e501c307496014 Mon Sep 17 00:00:00 2001 From: Brian Downs Date: Tue, 18 May 2021 13:57:40 -0700 Subject: [PATCH] add retention default and wire in s3 prune Signed-off-by: Brian Downs --- pkg/cli/cmds/etcd_snapshot.go | 2 +- pkg/cli/cmds/server.go | 2 +- pkg/etcd/etcd.go | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/cli/cmds/etcd_snapshot.go b/pkg/cli/cmds/etcd_snapshot.go index df0387d011..6829e1122e 100644 --- a/pkg/cli/cmds/etcd_snapshot.go +++ b/pkg/cli/cmds/etcd_snapshot.go @@ -122,7 +122,7 @@ func NewEtcdSnapshotSubcommands(delete, list, prune, save func(ctx *cli.Context) Action: prune, Flags: append(EtcdSnapshotFlags, &cli.IntFlag{ Name: "snapshot-retention", - Usage: "(db) Number of snapshots to retain", + Usage: "(db) Number of snapshots to retain. Default: 5", Destination: &ServerConfig.EtcdSnapshotRetention, Value: defaultSnapshotRentention, }), diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index c8171a5a50..187dd305ab 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -252,7 +252,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { }, &cli.IntFlag{ Name: "etcd-snapshot-retention", - Usage: "(db) Number of snapshots to retain", + Usage: "(db) Number of snapshots to retain Default: 5", Destination: &ServerConfig.EtcdSnapshotRetention, Value: defaultSnapshotRentention, }, diff --git a/pkg/etcd/etcd.go b/pkg/etcd/etcd.go index 58dd1c9e9e..04bdf96709 100644 --- a/pkg/etcd/etcd.go +++ b/pkg/etcd/etcd.go @@ -978,6 +978,14 @@ func (e *ETCD) PruneSnapshots(ctx context.Context) error { return errors.Wrap(err, "failed to get the snapshot dir") } + if e.config.EtcdS3 { + if e.initS3IfNil(ctx); err != nil { + return err + } + + return e.s3.snapshotRetention(ctx) + } + return snapshotRetention(e.config.EtcdSnapshotRetention, snapshotDir) }