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

fix(k8s): handle 404 exception when tagging image for deletion #1485

Merged
merged 4 commits into from
Jan 9, 2020

Conversation

solomonope
Copy link
Contributor

What this PR does / why we need it:
This PR allows a 404 error when tagging images in the registry for deletion fail silently and log a message

Which issue(s) this PR fixes:
#1472
Fixes #

Special notes for your reviewer:

Copy link
Collaborator

@edvald edvald left a comment

Choose a reason for hiding this comment

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

Had one comment to resolve. Also, the commit message is not really helpful. The category (which to be fair we have not documented much) should in this case be k8s and not "exception", and the message itself should describe more precisely what is being fixed, so the context is understandable without looking at the diff.

method: "DELETE",
})
} catch (err) {
log.debug(`${err.message} happend when deleting ${image}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to more specifically catch the error. If you just wrap the first query and explicitly catch a 404, you can just return without logging any error. Other errors should be thrown as usual.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the change, I have updated to only check for 404

Copy link
Collaborator

Choose a reason for hiding this comment

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

That works. I'd just remove that log line, don't think it's necessary. Then it's good to go!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@solomonope solomonope changed the title fix(exception): include exception handling fix(k8s): handle 404 exception when tagging image for deletion Jan 8, 2020
method: "DELETE",
})
} catch (err) {
if (err.response && !(err.response.status === 404)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor nitpick, but err.response.status !== 404 is a bit cleaner :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@solomonope solomonope merged commit f7c5ed4 into master Jan 9, 2020
@solomonope solomonope deleted the catch-exceptions branch February 13, 2020 11:17
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.

3 participants