Skip to content

Commit

Permalink
cmd-coreos-prune: Only add policy-cleanup when needed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gursewak1997 committed Nov 20, 2024
1 parent 5b8517c commit 50e9242
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/cmd-coreos-prune
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 50e9242

Please sign in to comment.