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

Ignore currently running backup for SLA calculation #68

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelog.d/20240612_121019_jb_running_backup_sla.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. A new scriv changelog fragment.

- Ignore currently running backups for SLA calculation
2 changes: 0 additions & 2 deletions src/backy/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ def sla_overdue(self) -> int:
"""Amount of time the SLA is currently overdue."""
if not self.backup.clean_history:
return 0
if self.status.startswith("running"):
return 0
age = backy.utils.now() - self.backup.clean_history[-1].timestamp
max_age = min(x["interval"] for x in self.schedule.schedule.values())
if age > max_age * 1.5:
Expand Down
6 changes: 6 additions & 0 deletions src/backy/tests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ def test_sla_over_time(daemon, clock, tmp_path, log):
job.backup.scan()
assert job.sla is False

# a running backup does not influence this.
job.update_status("running (slow)")
r = Revision.create(job.backup, {"daily"}, log)
r.write_info()
assert job.sla is False


def test_incomplete_revs_dont_count_for_sla(daemon, clock, tmp_path, log):
job = daemon.jobs["test01"]
Expand Down
Loading