Use etcd-snapshot-retention as default for s3 if etcd-s3-retention is not set

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/13788/head
Brad Davidson 2026-03-09 23:27:32 +00:00 committed by Brad Davidson
parent 36785d1993
commit f4bb1e60c3
3 changed files with 12 additions and 1 deletions

View File

@ -48,8 +48,12 @@ func commandSetup(app *cli.Context, cfg *cmds.Server) (*etcd.SnapshotRequest, *c
if app.IsSet("etcd-snapshot-retention") {
sr.Retention = &cfg.EtcdSnapshotRetention
}
if cfg.EtcdS3 {
// set default s3 retention from local snapshot retention
// preserves legacy behavior of local snapshot retention also affecting s3
if !app.IsSet("etcd-s3-retention") && app.IsSet("etcd-snapshot-retention") {
cfg.EtcdS3Retention = cfg.EtcdSnapshotRetention
}
sr.S3 = &config.EtcdS3{
AccessKey: cfg.EtcdS3AccessKey,
Bucket: cfg.EtcdS3BucketName,

View File

@ -213,6 +213,11 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
if cfg.EtcdS3Timeout <= 0 {
return errors.New("etcd-s3-timeout must be greater than 0s")
}
// set default s3 retention from local snapshot retention
// preserves legacy behavior of local snapshot retention also affecting s3
if !app.IsSet("etcd-s3-retention") && app.IsSet("etcd-snapshot-retention") {
cfg.EtcdS3Retention = cfg.EtcdSnapshotRetention
}
serverConfig.ControlConfig.EtcdS3 = &config.EtcdS3{
AccessKey: cfg.EtcdS3AccessKey,
Bucket: cfg.EtcdS3BucketName,

View File

@ -129,6 +129,8 @@ func (c *Controller) GetClient(ctx context.Context, etcdS3 *config.EtcdS3) (*Cli
// update ConfigSecret in defaults so that comparisons between current and default config
// ignore ConfigSecret when deciding if CLI configuration is present.
defaultEtcdS3.ConfigSecret = etcdS3.ConfigSecret
// also ignore retention, as it may have been defaulted from the etcd-snapshot-retention flag.
defaultEtcdS3.Retention = etcdS3.Retention
// 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.
// If config is not default, and secret name is set, warn that the secret is being ignored