Skip to content

Commit f4bb1e6

Browse files
committed
Use etcd-snapshot-retention as default for s3 if etcd-s3-retention is not set
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
1 parent 36785d1 commit f4bb1e6

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

pkg/cli/etcdsnapshot/etcd_snapshot.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ func commandSetup(app *cli.Context, cfg *cmds.Server) (*etcd.SnapshotRequest, *c
4848
if app.IsSet("etcd-snapshot-retention") {
4949
sr.Retention = &cfg.EtcdSnapshotRetention
5050
}
51-
5251
if cfg.EtcdS3 {
52+
// set default s3 retention from local snapshot retention
53+
// preserves legacy behavior of local snapshot retention also affecting s3
54+
if !app.IsSet("etcd-s3-retention") && app.IsSet("etcd-snapshot-retention") {
55+
cfg.EtcdS3Retention = cfg.EtcdSnapshotRetention
56+
}
5357
sr.S3 = &config.EtcdS3{
5458
AccessKey: cfg.EtcdS3AccessKey,
5559
Bucket: cfg.EtcdS3BucketName,

pkg/cli/server/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
213213
if cfg.EtcdS3Timeout <= 0 {
214214
return errors.New("etcd-s3-timeout must be greater than 0s")
215215
}
216+
// set default s3 retention from local snapshot retention
217+
// preserves legacy behavior of local snapshot retention also affecting s3
218+
if !app.IsSet("etcd-s3-retention") && app.IsSet("etcd-snapshot-retention") {
219+
cfg.EtcdS3Retention = cfg.EtcdSnapshotRetention
220+
}
216221
serverConfig.ControlConfig.EtcdS3 = &config.EtcdS3{
217222
AccessKey: cfg.EtcdS3AccessKey,
218223
Bucket: cfg.EtcdS3BucketName,

pkg/etcd/s3/s3.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ func (c *Controller) GetClient(ctx context.Context, etcdS3 *config.EtcdS3) (*Cli
129129
// update ConfigSecret in defaults so that comparisons between current and default config
130130
// ignore ConfigSecret when deciding if CLI configuration is present.
131131
defaultEtcdS3.ConfigSecret = etcdS3.ConfigSecret
132+
// also ignore retention, as it may have been defaulted from the etcd-snapshot-retention flag.
133+
defaultEtcdS3.Retention = etcdS3.Retention
132134

133135
// If config is default, try to load config from secret, and fail if it cannot be retrieved or if the secret name is not set.
134136
// If config is not default, and secret name is set, warn that the secret is being ignored

0 commit comments

Comments
 (0)