Add retention flag specific for s3

* Add retention flag specific for s3
* Add retention for the unit tests:

Signed-off-by: Vitor Savian <vitor.savian@suse.com>
This commit is contained in:
Vitor Savian
2025-07-28 13:42:09 -03:00
parent 17cfde1c82
commit 968460dfe8
10 changed files with 107 additions and 42 deletions

View File

@@ -124,6 +124,13 @@ var EtcdSnapshotFlags = []cli.Flag{
Destination: &ServerConfig.EtcdS3Region,
Value: "us-east-1",
},
&cli.IntFlag{
Name: "s3-retention",
Aliases: []string{"etcd-s3-retention"},
Usage: "(db) Number of s3 snapshots to retain.",
Destination: &ServerConfig.EtcdS3Retention,
Value: defaultSnapshotRentention,
},
&cli.StringFlag{
Name: "s3-folder",
Aliases: []string{"etcd-s3-folder"},

View File

@@ -105,6 +105,7 @@ type Server struct {
EtcdS3SecretKey string
EtcdS3SessionToken string
EtcdS3BucketName string
EtcdS3Retention int
EtcdS3BucketLookupType string
EtcdS3Region string
EtcdS3Folder string
@@ -480,6 +481,12 @@ var ServerFlags = []cli.Flag{
Usage: "(db) S3 folder",
Destination: &ServerConfig.EtcdS3Folder,
},
&cli.IntFlag{
Name: "etcd-s3-retention",
Usage: "(db) S3 retention limit",
Destination: &ServerConfig.EtcdS3Retention,
Value: defaultSnapshotRentention,
},
&cli.StringFlag{
Name: "etcd-s3-proxy",
Usage: "(db) Proxy server to use when connecting to S3, overriding any proxy-releated environment variables",

View File

@@ -65,6 +65,7 @@ func commandSetup(app *cli.Context, cfg *cmds.Server) (*etcd.SnapshotRequest, *c
Region: cfg.EtcdS3Region,
SecretKey: cfg.EtcdS3SecretKey,
SkipSSLVerify: cfg.EtcdS3SkipSSLVerify,
Retention: cfg.EtcdS3Retention,
Timeout: metav1.Duration{Duration: cfg.EtcdS3Timeout},
}
// extend request timeout to allow the S3 operation to complete

View File

@@ -210,6 +210,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
SecretKey: cfg.EtcdS3SecretKey,
SessionToken: cfg.EtcdS3SessionToken,
SkipSSLVerify: cfg.EtcdS3SkipSSLVerify,
Retention: cfg.EtcdS3Retention,
Timeout: metav1.Duration{Duration: cfg.EtcdS3Timeout},
}
}