@@ -48,6 +48,7 @@ var defaultEtcdS3 = &config.EtcdS3{
48
48
Timeout : metav1.Duration {
49
49
Duration : 5 * time .Minute ,
50
50
},
51
+ Retention : 5 ,
51
52
}
52
53
53
54
var (
@@ -386,13 +387,13 @@ func (c *Client) downloadSnapshotMetadata(ctx context.Context, key, file string)
386
387
387
388
// SnapshotRetention prunes snapshots in the configured S3 compatible backend for this specific node.
388
389
// Returns a list of pruned snapshot names.
389
- func (c * Client ) SnapshotRetention (ctx context.Context , retention int , prefix string ) ([]string , error ) {
390
- if retention < 1 {
390
+ func (c * Client ) SnapshotRetention (ctx context.Context , prefix string ) ([]string , error ) {
391
+ if c . etcdS3 . Retention < 1 {
391
392
return nil , nil
392
393
}
393
394
394
395
prefix = path .Join (c .etcdS3 .Folder , prefix )
395
- logrus .Infof ("Applying snapshot retention=%d to snapshots stored in s3://%s/%s" , retention , c .etcdS3 .Bucket , prefix )
396
+ logrus .Infof ("Applying snapshot retention=%d to snapshots stored in s3://%s/%s" , c . etcdS3 . Retention , c .etcdS3 .Bucket , prefix )
396
397
397
398
var snapshotFiles []minio.ObjectInfo
398
399
@@ -416,7 +417,7 @@ func (c *Client) SnapshotRetention(ctx context.Context, retention int, prefix st
416
417
snapshotFiles = append (snapshotFiles , info )
417
418
}
418
419
419
- if len (snapshotFiles ) <= retention {
420
+ if len (snapshotFiles ) <= c . etcdS3 . Retention {
420
421
return nil , nil
421
422
}
422
423
@@ -426,7 +427,7 @@ func (c *Client) SnapshotRetention(ctx context.Context, retention int, prefix st
426
427
})
427
428
428
429
deleted := []string {}
429
- for _ , df := range snapshotFiles [retention :] {
430
+ for _ , df := range snapshotFiles [c . etcdS3 . Retention :] {
430
431
logrus .Infof ("Removing S3 snapshot: s3://%s/%s" , c .etcdS3 .Bucket , df .Key )
431
432
432
433
key := path .Base (df .Key )
0 commit comments