Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Smart Remove behavior to really "keep one snapshot per week for n weeks" #1819

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ def smartRemoveKeepAll(self,
min_id = SID(min_date, self.config)
max_id = SID(max_date, self.config)

logger.debug("Keep all >= %s and < %s" %(min_id, max_id), self)
logger.debug("Keep all >= %s and < %s" %(min_id.withoutTag, max_id.withoutTag), self)

return set([sid for sid in snapshots if sid >= min_id and sid < max_id])

Expand Down Expand Up @@ -1562,7 +1562,7 @@ def smartRemoveKeepFirst(self,
min_id = SID(min_date, self.config)
max_id = SID(max_date, self.config)

logger.debug("Keep first >= %s and < %s" %(min_id, max_id), self)
logger.debug("Keep first >= %s and < %s" %(min_id.withoutTag, max_id.withoutTag), self)

for sid in snapshots:
# try to keep the first healthy snapshot
Expand Down Expand Up @@ -1683,7 +1683,7 @@ def smartRemoveList(self,
keep |= self.smartRemoveKeepFirst(
snapshots,
d,
d + datetime.timedelta(days=8),
d + datetime.timedelta(days=7),
Copy link
Member

@buhtz buhtz Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing the original code (especially smartRemoveKeepFirst()) and its behavior I am quit sure this wont work as intended. The two parameters in smartRemoveKeepFirst(), min_date and max_date are used like this:

d >= min_date and d < max_date

Because of the latest operator < a range of 8 is IMHO fine.

I will improve the test situation in near future. But I also have to do some refactoring first. So this topic won't be lost.

keep_healthy=True)
d -= datetime.timedelta(days=7)

Expand Down