-
Notifications
You must be signed in to change notification settings - Fork 126
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
Refresh metadata cache after failed package installation #3348
base: main
Are you sure you want to change the base?
Conversation
c736cd9
to
793ac8a
Compare
tmt/steps/prepare/install.py
Outdated
except Exception: | ||
# Refresh cache in case of recent but not updated change do repodata | ||
self.guest.package_manager.refresh_metadata() | ||
self._install() |
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 wonder whether should capture the first exception as well - this way, the original one is lost, with all its data. How about something like this?
try:
self._install()
except Exception as exc1:
# We do not have any special handling for exceptions raised by the following code.
# Wrapping them with try/except gives us a chance to attach the original exception
# to whatever the code may raise, and therefore preserve the information attached
# to the original exception.
try:
# Refresh cache in case of recent but not updated change do repodata
self.guest.package_manager.refresh_metadata()
self._install()
except Exception as exc2:
raise exc2 from ex1
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.
You're right, that seems like an unnecessary loss of data - better to catch them both. I used your code, if that's alright:)
/packit test |
9c21ff0
to
a998cbf
Compare
Fixes #3277
When testing I found out that there is different behavior in dnf5 compared to dnf4, where a mere
dnf makecache
would be enough, but dnf5 needs the --refresh option as well (ordnf clean metadata
ordnf clean expire-cache
), see https://bugzilla.redhat.com/show_bug.cgi?id=2324177Not sure about the Exception being too generic. Should I create a new one, something like InstallationError? And notify the user through logger as to why
metadata --refresh
is happening?Pull Request Checklist