Skip to content

Commit e6895c8

Browse files
author
Dmitry Shibut
committed
Change certain DNF command failures to throw StopActorExecutionError error instead of CalledProcessError
When certain DNF commands fail, an unhandled CalledProcessError is thrown, halting the process and preventing cleanup actors from executing during preupgrade. Replacing it with StopActorExecutionError ensures the process still fails but executes the required actors.
1 parent ffba452 commit e6895c8

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

repos/system_upgrade/common/libraries/dnfconfig.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,16 @@ def _set_excluded_pkgs(context, pkglist, disable_plugins):
105105

106106
try:
107107
context.call(cmd)
108-
except CalledProcessError:
108+
except CalledProcessError as e:
109109
api.current_logger().error('Cannot set the dnf configuration')
110-
raise
110+
raise StopActorExecutionError(
111+
message='Cannot set the DNF configuration with the command: {}'.format(cmd),
112+
details={
113+
'details': 'An exception raised: {}'.format(str(e)),
114+
'stdout': e.stdout,
115+
'stderr': e.stderr
116+
}
117+
)
111118
api.current_logger().debug('The DNF configuration has been updated to exclude leapp packages.')
112119

113120

@@ -147,7 +154,14 @@ def _set_repository_state(context, repo_id, new_state):
147154

148155
try:
149156
context.call(cmd)
150-
except CalledProcessError:
157+
except CalledProcessError as e:
151158
api.current_logger().error('Cannot set the dnf configuration')
152-
raise
159+
raise StopActorExecutionError(
160+
message='Cannot set the DNF configuration with the command: {}'.format(cmd),
161+
details={
162+
'details': 'An exception raised: {}'.format(str(e)),
163+
'stdout': e.stdout,
164+
'stderr': e.stderr
165+
}
166+
)
153167
api.current_logger().debug('Repository {} has been {}'.format(repo_id, new_state))

0 commit comments

Comments
 (0)