mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-02-02 20:59:02 +08:00
fix delete_old_oci_images.py
Previously, the delete_old_oci_images.py script sometimes caused a traceback when trying to get the date from the JSON response for an OIC image blob. This was because it was trying to read a JSON value that didnt exist in some cases. This change simply skips those images -- might update this in the future to fins a fallback date to use, but for now just skip them. Signed-off-by: Ryan Lerch <rlerch@redhat.com>
This commit is contained in:
@@ -140,6 +140,11 @@ def main():
|
||||
|
||||
# Find when a blob was created
|
||||
age = resp.json().get("created")
|
||||
if age is None:
|
||||
result["stdout_lines"].append(
|
||||
"Could not get date for {}:{} -- skipping".format(repo, digest)
|
||||
)
|
||||
continue
|
||||
# Check if the blob is older than "days"
|
||||
if datetime.strptime(age[:10], "%Y-%m-%d") <= datetime.now() - timedelta(days=days):
|
||||
if not check_mode:
|
||||
|
||||
Reference in New Issue
Block a user