From 2883c54e67b6e3f9714ee1d592fe4224de1abd75 Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: Fri, 28 Apr 2023 13:58:24 +1000 Subject: [PATCH] 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 --- library/delete_old_oci_images.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/delete_old_oci_images.py b/library/delete_old_oci_images.py index 74ebb08ef1..981c5da8cd 100644 --- a/library/delete_old_oci_images.py +++ b/library/delete_old_oci_images.py @@ -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: