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

Added check for ALLOWED_CONTENT_CHECKSUMS that Artifacts are missing #953

Merged
merged 1 commit into from
Oct 12, 2020

Conversation

daviddavis
Copy link
Contributor

fixes #7487

Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html

@pulpbot
Copy link
Member

pulpbot commented Oct 6, 2020

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()
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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?

Copy link
Contributor Author

@daviddavis daviddavis Oct 8, 2020

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.

Copy link
Member

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.

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 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?

Copy link
Member

Choose a reason for hiding this comment

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

Jeps!

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

@bmbouter bmbouter left a 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!

@ipanova
Copy link
Member

ipanova commented Oct 7, 2020

the change looks good to me however i don't understand why travis fails.

I have read on your scrum and seen that dynaconf had a bug

@daviddavis daviddavis force-pushed the issue7487 branch 2 times, most recently from ac3909b to 3c11e36 Compare October 9, 2020 19:18
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.

None yet

5 participants