Skip to content

Conversation

@gursewak1997
Copy link
Member

@gursewak1997 gursewak1997 commented Nov 18, 2024

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.

With the current code, it tries to update the builds.json for every build in the stream having the respective action in gc-policy.yaml not taking into consideration the datetime for eg. if the script will prune all containers that are 2weeks ago, the script will try to update every build in that stream with "containers": true no matter if the pruning ran on that build or not.

if "images" not in policy_cleanup:
policy_cleanup["images"] = True
for action, completed_arches in action_completion_status.items():
if set(completed_arches) == set(build["arches"]): # Ensure all arches are completed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to think of a case we would get to this code where not all architectures were completed.. If that were the case wouldn't the code have thrown an exception?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct; technically, we could bypass considering the angle of architectures in these changes. However, assuming that pruning is complete for a build_id after processing just one architecture felt inconsistent.
I could revise the implementation to operate that way, and it would technically work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this when we run pruning on the first arch should suffice.
action_completion_status[action] = True

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

for build in reversed(builds):
build_id = build["id"]
build_date = parse_fcos_version_to_timestamp(build_id)
action_completion_status = {action: False for action in policy[stream]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: this could probably just be a list at this point

Suggested change
action_completion_status = {action: False for action in policy[stream]}
actions_completed = []

dustymabe
dustymabe previously approved these changes Nov 19, 2024
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.
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gursewak1997 gursewak1997 enabled auto-merge (rebase) November 19, 2024 20:18
@gursewak1997 gursewak1997 merged commit 64348e5 into coreos:main Nov 19, 2024
5 checks passed
@gursewak1997 gursewak1997 deleted the fix-builds-update-bug branch November 19, 2024 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants