Skip to content

Commit 946d66f

Browse files
committed
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.
1 parent 8b32fc8 commit 946d66f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/cmd-coreos-prune

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,16 @@ def main():
190190
else:
191191
print(f"No container tags to prune for build {build_id}.")
192192
actions_completed.append(action) # Append action to completed list
193-
# Update policy-cleanup for completed actions
194-
policy_cleanup = build.setdefault("policy-cleanup", {})
195-
for action in actions_completed:
196-
if action == "images":
197-
policy_cleanup["images-kept"] = images_to_keep
198-
else:
199-
policy_cleanup[action] = True
193+
# Only add policy-cleanup for the build in builds.json if any
194+
# of the cleanup actions were completed.
195+
if actions_completed:
196+
policy_cleanup = build.setdefault("policy-cleanup", {})
197+
# Update policy-cleanup for completed actions
198+
for action in actions_completed:
199+
if action == "images":
200+
policy_cleanup["images-kept"] = images_to_keep
201+
else:
202+
policy_cleanup[action] = True
200203

201204
if pruned_build_ids:
202205
if "tombstone-builds" not in builds_json_data:

0 commit comments

Comments
 (0)