Commit 2b42d881 authored by Vitor's avatar Vitor Committed by Vitor Savian

Fixed the etcd retention to delete orphaned snapshots

Signed-off-by: 's avatarVitor <vitor.savian@suse.com>
parent 124c22ba
...@@ -2029,15 +2029,14 @@ func snapshotRetention(retention int, snapshotPrefix string, snapshotDir string) ...@@ -2029,15 +2029,14 @@ func snapshotRetention(retention int, snapshotPrefix string, snapshotDir string)
return nil return nil
} }
nodeName := os.Getenv("NODE_NAME") logrus.Infof("Applying local snapshot retention policy: retention: %d, snapshotPrefix: %s, directory: %s", retention, snapshotPrefix, snapshotDir)
logrus.Infof("Applying local snapshot retention policy: retention: %d, snapshotPrefix: %s, directory: %s", retention, snapshotPrefix+"-"+nodeName, snapshotDir)
var snapshotFiles []os.FileInfo var snapshotFiles []os.FileInfo
if err := filepath.Walk(snapshotDir, func(path string, info os.FileInfo, err error) error { if err := filepath.Walk(snapshotDir, func(path string, info os.FileInfo, err error) error {
if err != nil { if err != nil {
return err return err
} }
if strings.HasPrefix(info.Name(), snapshotPrefix+"-"+nodeName) { if strings.HasPrefix(info.Name(), snapshotPrefix) {
snapshotFiles = append(snapshotFiles, info) snapshotFiles = append(snapshotFiles, info)
} }
return nil return nil
......
...@@ -212,8 +212,7 @@ func (s *S3) Download(ctx context.Context) error { ...@@ -212,8 +212,7 @@ func (s *S3) Download(ctx context.Context) error {
// snapshotPrefix returns the prefix used in the // snapshotPrefix returns the prefix used in the
// naming of the snapshots. // naming of the snapshots.
func (s *S3) snapshotPrefix() string { func (s *S3) snapshotPrefix() string {
nodeName := os.Getenv("NODE_NAME") fullSnapshotPrefix := s.config.EtcdSnapshotName
fullSnapshotPrefix := s.config.EtcdSnapshotName + "-" + nodeName
var prefix string var prefix string
if s.config.EtcdS3Folder != "" { if s.config.EtcdS3Folder != "" {
prefix = filepath.Join(s.config.EtcdS3Folder, fullSnapshotPrefix) prefix = filepath.Join(s.config.EtcdS3Folder, fullSnapshotPrefix)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment