From 467c01c49f94e9ad9738998a2a8aa2ec4b5dd196 Mon Sep 17 00:00:00 2001 From: Vitor Date: Thu, 3 Aug 2023 12:22:28 -0300 Subject: [PATCH] Fixed the etcd retention to delete orphaned snapshots Signed-off-by: Vitor --- pkg/etcd/etcd.go | 5 ++--- pkg/etcd/s3.go | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/etcd/etcd.go b/pkg/etcd/etcd.go index ae84ca3b8e67..ebb3bb51835f 100644 --- a/pkg/etcd/etcd.go +++ b/pkg/etcd/etcd.go @@ -2029,15 +2029,14 @@ func snapshotRetention(retention int, snapshotPrefix string, snapshotDir string) return nil } - nodeName := os.Getenv("NODE_NAME") - logrus.Infof("Applying local snapshot retention policy: retention: %d, snapshotPrefix: %s, directory: %s", retention, snapshotPrefix+"-"+nodeName, snapshotDir) + logrus.Infof("Applying local snapshot retention policy: retention: %d, snapshotPrefix: %s, directory: %s", retention, snapshotPrefix, snapshotDir) var snapshotFiles []os.FileInfo if err := filepath.Walk(snapshotDir, func(path string, info os.FileInfo, err error) error { if err != nil { return err } - if strings.HasPrefix(info.Name(), snapshotPrefix+"-"+nodeName) { + if strings.HasPrefix(info.Name(), snapshotPrefix) { snapshotFiles = append(snapshotFiles, info) } return nil diff --git a/pkg/etcd/s3.go b/pkg/etcd/s3.go index 42b4ca838786..1acb9f1c82bd 100644 --- a/pkg/etcd/s3.go +++ b/pkg/etcd/s3.go @@ -212,8 +212,7 @@ func (s *S3) Download(ctx context.Context) error { // snapshotPrefix returns the prefix used in the // naming of the snapshots. func (s *S3) snapshotPrefix() string { - nodeName := os.Getenv("NODE_NAME") - fullSnapshotPrefix := s.config.EtcdSnapshotName + "-" + nodeName + fullSnapshotPrefix := s.config.EtcdSnapshotName var prefix string if s.config.EtcdS3Folder != "" { prefix = filepath.Join(s.config.EtcdS3Folder, fullSnapshotPrefix)