Skip to content

Commit

Permalink
automatic: Return an error when transaction fails (RhBug:2170093)
Browse files Browse the repository at this point in the history
In case of no global error occurred within the transaction, we still need to check state of individual transaction items for any failure.

This is matching the logic in `BaseCli.do_transaction` method, where the error is emitted after printing the transaction summary.

= changelog =
msg: automatic: Return an error when transaction fails
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2170093
  • Loading branch information
jan-kolarik authored and j-mracek committed May 17, 2023
1 parent a798d23 commit 9e4f0eb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dnf/automatic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ def main(args):

gpgsigcheck(base, trans.install_set)
base.do_transaction()

# In case of no global error occurred within the transaction,
# we need to check state of individual transaction items.
for tsi in trans:
if tsi.state == libdnf.transaction.TransactionItemState_ERROR:
raise dnf.exceptions.Error(_('Transaction failed'))

emitters.notify_applied()
emitters.commit()

Expand Down

0 comments on commit 9e4f0eb

Please sign in to comment.