From d59623599c67a324bb313e04e08a9c5dda33aac8 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Thu, 14 May 2026 10:25:05 -0400 Subject: [PATCH] Fix GCS backup check: align staleness cutoff and add size validation GCS check used a 72h cutoff but only listed 2 days of prefixes (~48h), making the staleness check unreachable. Also added 1MB minimum file size validation to match the S3 check. --- lambda/backup-verification/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lambda/backup-verification/app.py b/lambda/backup-verification/app.py index 4935e03..77c886d 100644 --- a/lambda/backup-verification/app.py +++ b/lambda/backup-verification/app.py @@ -69,11 +69,13 @@ def _check_gcs(): blobs.extend(list(bucket.list_blobs(prefix=f"archive/{date_prefix}/"))) if not blobs: return False, "GCS Offsite: No objects found under archive/ for last 2 days" - cutoff = now - timedelta(hours=72) + cutoff = now - timedelta(hours=48) latest = max(blobs, key=lambda b: b.updated) if latest.updated < cutoff: age = (now - latest.updated).total_seconds() / 3600 return False, f"GCS Offsite: Latest object is {age:.0f}h old ({latest.name})" + if latest.size < 1_000_000: + return False, f"GCS Offsite: Latest dump suspiciously small ({latest.size} bytes)" return True, f"GCS Offsite: OK — {latest.name} ({latest.size / 1_000_000:.1f} MB)" except Exception as e: return False, f"GCS Offsite: Error — {e}"