From 946d66fdb95ae63f2ce047d3e6574584903a5666 Mon Sep 17 00:00:00 2001 From: gursewak1997 Date: Tue, 19 Nov 2024 22:42:50 -0800 Subject: [PATCH] cmd-coreos-prune: Only add policy-cleanup when needed We are adding empty policy-cleanup key:value for the build even when no pruning action in completed. Added changes to not do that anymore. --- src/cmd-coreos-prune | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cmd-coreos-prune b/src/cmd-coreos-prune index 1194ca560d..c85f0ad7d9 100755 --- a/src/cmd-coreos-prune +++ b/src/cmd-coreos-prune @@ -190,13 +190,16 @@ def main(): else: print(f"No container tags to prune for build {build_id}.") actions_completed.append(action) # Append action to completed list - # Update policy-cleanup for completed actions - policy_cleanup = build.setdefault("policy-cleanup", {}) - for action in actions_completed: - if action == "images": - policy_cleanup["images-kept"] = images_to_keep - else: - policy_cleanup[action] = True + # Only add policy-cleanup for the build in builds.json if any + # of the cleanup actions were completed. + if actions_completed: + policy_cleanup = build.setdefault("policy-cleanup", {}) + # Update policy-cleanup for completed actions + for action in actions_completed: + if action == "images": + policy_cleanup["images-kept"] = images_to_keep + else: + policy_cleanup[action] = True if pruned_build_ids: if "tombstone-builds" not in builds_json_data: