-
Notifications
You must be signed in to change notification settings - Fork 170
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
Conversation
src/cmd-coreos-prune
Outdated
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This detection wasn't working properly and causing the
images
action to get run even for builds where the images had already been pruned.