mirror of
https://github.com/Sea-Haven-Industries/forgejo.git
synced 2026-09-30 17:53:10 +00:00
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.
This commit is contained in:
parent
0ab9cc9f30
commit
d59623599c
1 changed files with 3 additions and 1 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue