(bugfix) Mark retention failures as backup warnings
Add a warning status for BackupRun records so successful snapshots are not reported as failed when post-run SQL retention fails. Keep the prune error in the run result, link the successful snapshot, and let the management command complete with a warning instead of raising a backup failure. Include warning runs in backup trend summaries and add a regression test for successful backups with failed retention cleanup.
This commit is contained in:
@@ -13,7 +13,7 @@ from .models import BackupRun, GlobalConfig, HostConfig, SnapshotRecord
|
||||
def collect_dashboard_stats(*, hosts: Iterable[HostConfig], global_config: GlobalConfig | None) -> dict[str, Any]:
|
||||
runs = list(
|
||||
BackupRun.objects.select_related("host", "snapshot")
|
||||
.filter(status=BackupRun.Status.SUCCESS)
|
||||
.filter(status__in=_COMPLETED_BACKUP_STATUSES)
|
||||
.order_by("-started_at", "-created_at")[:100]
|
||||
)
|
||||
real_runs = [_run_summary(run) for run in runs if _is_real_run(run)]
|
||||
@@ -52,7 +52,7 @@ def collect_dashboard_stats(*, hosts: Iterable[HostConfig], global_config: Globa
|
||||
|
||||
|
||||
def collect_host_stats(*, host: HostConfig, limit: int = 8) -> dict[str, Any]:
|
||||
runs = list(host.runs.select_related("snapshot").filter(status=BackupRun.Status.SUCCESS).order_by("-started_at", "-created_at")[:50])
|
||||
runs = list(host.runs.select_related("snapshot").filter(status__in=_COMPLETED_BACKUP_STATUSES).order_by("-started_at", "-created_at")[:50])
|
||||
real_runs = [_run_summary(run) for run in runs if _is_real_run(run)]
|
||||
trend_runs = [run for run in real_runs if run["has_stats"]][:limit]
|
||||
latest_snapshot = host.snapshots.order_by("-started_at", "-discovered_at", "-id").first()
|
||||
@@ -198,3 +198,6 @@ def _int_at(data: dict[str, Any], *keys: str) -> int | None:
|
||||
if isinstance(value, float):
|
||||
return int(value)
|
||||
return None
|
||||
|
||||
|
||||
_COMPLETED_BACKUP_STATUSES = [BackupRun.Status.SUCCESS, BackupRun.Status.WARNING]
|
||||
|
||||
Reference in New Issue
Block a user