Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Fix max backup deletion #26

Closed
wants to merge 2 commits into from

Conversation

Marlinc
Copy link

@Marlinc Marlinc commented Nov 11, 2019

Copy of coreos#2116 by @mdkrajewski

etcd-backup-operator: fixed sorting of etcd backups to ensure deletion of only the oldest backups when rotating

Issue: When rotating backups based on a maximum number allowed, newer backups were being deleted when the number of digits in an etcd store revision increased.
E.g., when "v99" became "v100", the newer "v100" backup was being deleted, because the "1" in "100" was sorted to come before the first "9" in "99".

Fix: This new sorting method relies on the timestamp in each backup path, rather than the revision number.
The reason the timestamp is given precedence over the revision when sorting is because the revision could potentially go backwards when an older backup is restored.
See my comment in pkg/backup/util/util.go's SortableBackupPaths type for more details.

Fixes coreos#2113

Matthew Krajewski added 2 commits August 28, 2019 15:26
…n of only the oldest backups when rotating

When rotating backups based on a maximum number allowed, newer backups were being deleted when the number of digits in an etcd store revision increased.
E.g., when "v99" became "v100", the newer "v100" backup was being deleted, because the "1" in "100" was sorted to come before the first "9" in "99".
This new sorting method relies on the timestamp in each backup path, rather than the revision number.
The reason the timestamp is given precedence over the revision when sorting is because the revision could potentially go backwards when an older backup is restored.
See my comment in pkg/backup/util/util.go's SortableBackupPaths type for more details.

Fixes coreos#2113
@Marlinc
Copy link
Author

Marlinc commented Nov 11, 2019

@mdkrajewski could you maybe recreate this PR yourself?

@mdkrajewski
Copy link

@mdkrajewski could you maybe recreate this PR yourself?

@Marlinc I'd be happy to do that if you like. Just now I tried, but GitHub saw that it was the same as this PR, and didn't let me create a duplicate. Is there some reason why it would be better for me to recreate the PR in this repo instead of you?

@Marlinc
Copy link
Author

Marlinc commented Nov 17, 2019

Hey @mdkrajewski,

Thanks for checking, if you open the PR then it will be attributed to you instead of me. I'll close the PR on this side.

@Marlinc Marlinc closed this Nov 17, 2019
@mdkrajewski
Copy link

...if you open the PR then it will be attributed to you instead of me.

@Marlinc OK, got it. Thanks! :)
Here's the new PR: #35

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Ensure max backup bug
2 participants