-
Notifications
You must be signed in to change notification settings - Fork 107
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
Added check for ALLOWED_CONTENT_CHECKSUMS that Artifacts are missing #953
Conversation
Attached issue: https://pulp.plan.io/issues/7487 |
# our check could fail if the table hasn't been created yet or we can't get a db connection | ||
pass | ||
finally: | ||
connection.close() |
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.
⚡
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'd prefer if we could be more specific about the exception we want to pass
. We would not need to reraise ImproperlyConfigured
in that case.
Also is it possible, that connection.close()
raises an error?
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'd prefer if we could be more specific about the exception we want to pass. We would not need to reraise ImproperlyConfigured in that case.
My thought about catching a generic Exception
is that there's a wide variety of different exceptions that could be raised. In most cases, I think we just want to forgo checking ALLOWED_CONTENT_CHECKSUMS and not raise ImproperlyConfigured (which pass
should accomplish).
Also is it possible, that connection.close() raises an error?
This is possible. I will add a try/except.
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.
Moving the connection.close() into the existing try/except I think would make sense.
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 can do that. I didn't put the connection.close()
in the try block because I assumed that it might not be reached if an exception gets thrown and thus the connection might not get closed properly. But I guess at that point, if an exception gets thrown, the process is mostly likely going to exit anyway?
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.
Jeps!
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.
So will this work out so well for us? We had to add this explicit close because not having it was secretly leaving a connection open. If we silence an error here and continue we're back in that situation. If there is a problem to the extent that the close()
call fails, I think it would be better for users to know that and have that be a fatal exception for Pulp.
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.
It depends. I think the problem with not catching close()
exceptions is that we might be halting the code in cases where we actually want the code to proceed. I did some more testing though and it looks my previous statement about close()
was incorrect. close()
looks like it doesn't tend to raise exceptions in cases where connection.cursor()
does (eg there's no db initialized, bad db password, etc). So I think not rescuing here is probably the correct choice.
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 the code as-is is the strongest, but if @mdellweg and @daviddavis, you'd like to do it differently feel free to adjust. I'm leaving the lgtm I put on it with support for either approach.
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.
@daviddavis thanks that is a good analysis and probably the right answer to my question.
@bmbouter I'm retiring my concerns.
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.
Looks good, thank you!
I have read on your scrum and seen that dynaconf had a bug |
ac3909b
to
3c11e36
Compare
fixes #7487
Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html