Skip to content

Commit 64348e5

Browse files
committed
cmd-coreos-prune: Ensure action completion of each build
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.
1 parent 10260a4 commit 64348e5

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/cmd-coreos-prune

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def main():
125125
for build in reversed(builds):
126126
build_id = build["id"]
127127
build_date = parse_fcos_version_to_timestamp(build_id)
128+
actions_completed = []
128129

129130
# For each build, iterate over arches first to minimize downloads of meta.json per arch
130131
for arch in build["arches"]:
@@ -188,20 +189,14 @@ def main():
188189
prune_container(tag, args.dry_run, container_repo, args.registry_auth_file)
189190
else:
190191
print(f"No container tags to prune for build {build_id}.")
191-
# Update policy-cleanup after pruning actions for the architecture
192+
actions_completed.append(action) # Append action to completed list
193+
# Update policy-cleanup for completed actions
192194
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
201-
policy_cleanup["images-kept"] = images_to_keep
202-
case "containers":
203-
if "containers" not in policy_cleanup:
204-
policy_cleanup["containers"] = True
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
205200

206201
if pruned_build_ids:
207202
if "tombstone-builds" not in builds_json_data:

0 commit comments

Comments
 (0)