Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd-coreos-prune: fix skipping of images action #4021

Merged
merged 2 commits into from
Feb 10, 2025
Merged

Conversation

dustymabe
Copy link
Member

This detection wasn't working properly and causing the images action to get run even for builds where the images had already been pruned.

if action != "images":
print(f"\t\tBuild {build_id} has already had {action} pruning completed")
continue
print(f"action {action} is in previous cleanup section")
Copy link
Member

Choose a reason for hiding this comment

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

Leftover? Seems redundant with the next print statement.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it was part of my debugging - will drop it.

if e.response['Error']['Code'] == 'NoSuchKey':
print(f"\t\t\t{bucket}/{image_prefix} already pruned.")
else:
errors.append(e)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, feels like it's still worth a comment somewhere in this area that the API returns 204 in the ENOENT case (and/or link to the docs page). As someone reviewing this code, I wouldn't have guessed that so my first thought would've been that it's a bug.

Copy link
Member Author

Choose a reason for hiding this comment

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

added a comment

This detection wasn't working properly and causing the `images`
action to get run even for builds where the images had already
been pruned.
Apparently delete object won't return a NoSuchKey error if the
object doesn't exist.

I stumbled upon this because our handling for the images action
meant we were calling prune_images() even for builds that had
already had images pruned and the logs were telling me it was
deleting the images again when it should have been telling me

```
XYZ.vmdk already pruned
```

Turns out the delete_object returns a `204 Success (No Content)`
response when the key doesn't exist.
https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html#API_DeleteObject_RequestSyntax

Let's just delete this code in here since it's dead code and can
be confusing to future code readers.

The prior commit to this one will try to ensure we don't end up in
this code path if the images have already been pruned for a build.
@jlebon jlebon merged commit 2c6be44 into coreos:main Feb 10, 2025
5 checks passed
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