Skip to content

Commit

Permalink
cmd-coreos-prune: Ensure action completion of each build
Browse files Browse the repository at this point in the history
Refactor policy-cleanup updates to ensure action completion across all
arches. Added action_completion_status to track completed actions
per arch. This bug came after we refactored the code to to iterate by
build, arch, then action.
  • Loading branch information
gursewak1997 committed Nov 19, 2024
1 parent 10260a4 commit 64348e5
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/cmd-coreos-prune
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def main():
for build in reversed(builds):
build_id = build["id"]
build_date = parse_fcos_version_to_timestamp(build_id)
actions_completed = []

# For each build, iterate over arches first to minimize downloads of meta.json per arch
for arch in build["arches"]:
Expand Down Expand Up @@ -188,20 +189,14 @@ def main():
prune_container(tag, args.dry_run, container_repo, args.registry_auth_file)
else:
print(f"No container tags to prune for build {build_id}.")
# Update policy-cleanup after pruning actions for the architecture
actions_completed.append(action) # Append action to completed list
# Update policy-cleanup for completed actions
policy_cleanup = build.setdefault("policy-cleanup", {})
for action in policy[stream].keys(): # Only update actions specified in policy[stream]
match action:
case "cloud-uploads":
if "cloud-uploads" not in policy_cleanup:
policy_cleanup["cloud-uploads"] = True
case "images":
if "images" not in policy_cleanup:
policy_cleanup["images"] = True
policy_cleanup["images-kept"] = images_to_keep
case "containers":
if "containers" not in policy_cleanup:
policy_cleanup["containers"] = True
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 64348e5

Please sign in to comment.