-
Notifications
You must be signed in to change notification settings - Fork 45
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
salt: close rpm DB & yum repo/cache #1971
Conversation
Hello alexandre-allard-scality,My role is to assist you with the merge of this Status report is not available. |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list:
|
@@ -198,6 +198,8 @@ def check_pkg_availability(pkgs_info): | |||
try: | |||
ybase.install(name=name, version=version, release=release) | |||
except yum.Errors.InstallError as exc: | |||
ybase.closeRpmDB() |
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.
Not too fond of doing it this way, because there's now one close
path in an except
and a later finally
. There are better ways to do error handling with resource releasing.
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.
implementing a python context and using with
will close the object every time I guess
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.
As this except raise right after this do not really matter but indeed I agree it's cleaner to do one big try - finally
.
Exceot if something else is raised ... true
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.
Makes sense, you can wrap the whole for
loop in try/finally
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.
context manager are the way to handle this kind of things, they are the Python way of implementing RAII-like behavior.
@@ -198,6 +198,8 @@ def check_pkg_availability(pkgs_info): | |||
try: | |||
ybase.install(name=name, version=version, release=release) | |||
except yum.Errors.InstallError as exc: | |||
ybase.closeRpmDB() |
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.
Makes sense, you can wrap the whole for
loop in try/finally
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list:
The following reviewers are expecting changes from the author, or must review again: |
Just tested on my machine, it fixed the issue described in #1970 for me |
We forgot to close databases after checking the presence of packages in repositories, it can lead to DB related errors when trying to use yum just after calling the salt custom module Refs: #1970
228c281
to
2112ae0
Compare
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.
Thanks! This PR would be a good candidate for a changelog entry IMO, so let's not close the issue yet
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list:
|
Consider adding a GNU-style |
/approve |
In the queueThe changeset has received all authorizations and has been added to the The changeset will be merged in:
The following branches will NOT be impacted:
There is no action required on your side. You will be notified here once IMPORTANT Please do not attempt to modify this pull request.
If you need this pull request to be removed from the queue, please contact a The following options are set: approve |
Creating another PR to add |
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
Please check the status of the associated issue None. Goodbye alexandre-allard-scality. |
We forgot to close databases after checking the presence
of packages in repositories, it can lead to DB related errors
when trying to use yum just after calling the salt custom module
Refs: #1970
Component: salt
Context: RPM & yum DB not closed
Acceptance criteria: successful
./doit.sh vagrant_up
See: #1970