Skip to content

Commit ffb1b48

Browse files
committed
cmd-coreos-prune: Ensure action completion of each build
Refactor policy-cleanup updates to ensure action completion across all arches. Modified to track completed actions per arch. This bug came after we refactored the code to to iterate by build, arch, then action.
1 parent 2ba481e commit ffb1b48

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/cmd-coreos-prune

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ def main():
125125
for build in reversed(builds):
126126
build_id = build["id"]
127127
build_date = parse_fcos_version_to_timestamp(build_id)
128+
# Initialize action status for all arches
129+
action_completion_status = {action: [] for action in policy[stream]}
128130

129131
# For each build, iterate over arches first to minimize downloads of meta.json per arch
130132
for arch in build["arches"]:
@@ -188,20 +190,14 @@ def main():
188190
prune_container(tag, args.dry_run, container_repo, args.registry_auth_file)
189191
else:
190192
print(f"No container tags to prune for build {build_id}.")
193+
action_completion_status[action].append(arch) # Track success for this action and arch
191194
# Update policy-cleanup after pruning actions for the architecture
192195
policy_cleanup = build.setdefault("policy-cleanup", {})
193-
for action in policy[stream].keys(): # Only update actions specified in policy[stream]
194-
match action:
195-
case "cloud-uploads":
196-
if "cloud-uploads" not in policy_cleanup:
197-
policy_cleanup["cloud-uploads"] = True
198-
case "images":
199-
if "images" not in policy_cleanup:
200-
policy_cleanup["images"] = True
196+
for action, completed_arches in action_completion_status.items():
197+
if set(completed_arches) == set(build["arches"]): # Ensure all arches are completed
198+
policy_cleanup[action] = True
199+
if action == "images":
201200
policy_cleanup["images-kept"] = images_to_keep
202-
case "containers":
203-
if "containers" not in policy_cleanup:
204-
policy_cleanup["containers"] = True
205201

206202
if pruned_build_ids:
207203
if "tombstone-builds" not in builds_json_data:

0 commit comments

Comments
 (0)