Bug 1630113

Summary: Transaction callbacks use action constants that aren't part of the callback API
Product: [Fedora] Fedora Reporter: Adam Williamson <awilliam>
Component: dnfAssignee: Daniel Mach <dmach>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 31CC: dmach, mblaha, packaging-team-maint, rpm-software-management, vmukhame
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: dnf-4.2.8-1.fc30 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-09-06 12:30:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Williamson 2018-09-18 02:15:28 UTC
I've been trying to debug a dnfdragora crash:

https://bugzilla.redhat.com/show_bug.cgi?id=1624652

If I got it right, what's basically going on is that a transaction progress callback is using 'action' values that aren't defined in the callback API. The callback API includes these package actions:

PKG_DOWNGRADE = dnf.transaction.PKG_DOWNGRADE  # :api
PKG_INSTALL = dnf.transaction.PKG_INSTALL  # :api
PKG_OBSOLETE = dnf.transaction.PKG_OBSOLETE  # :api
PKG_REINSTALL = dnf.transaction.PKG_REINSTALL  # :api
PKG_REMOVE = dnf.transaction.PKG_ERASE  # :api
PKG_UPGRADE = dnf.transaction.PKG_UPGRADE  # :api

PKG_CLEANUP = dnf.transaction.PKG_CLEANUP  # :api
PKG_VERIFY = dnf.transaction.PKG_VERIFY  # :api
PKG_SCRIPTLET = dnf.transaction.PKG_SCRIPTLET  # :api

the values for those are, respectively:

2
1
4
9
8
6
101
102
103

but in the traceback of the dnfdragora bug, we catch the value '7' showing up for the action:

Local variables in innermost frame:
self: <dnfdragora.dnf_backend.DnfRootBackend object at 0x7fda65f7f320>
package: 'texlive-xetex,7,20180414,19.fc29,x86_64,@System'
action: 7
te_current: 0
te_total: 28
ts_current: 119
ts_total: 232
num: ' ( 119/232 )'
name: 'texlive-xetex-7:20180414-19.fc29.x86_64'

If we look in dnf.transaction, we see some *other* package action constants which aren't in the callback API:

PKG_DOWNGRADE = libdnf.transaction.TransactionItemAction_DOWNGRADE
PKG_DOWNGRADED = libdnf.transaction.TransactionItemAction_DOWNGRADED
PKG_INSTALL = libdnf.transaction.TransactionItemAction_INSTALL
PKG_OBSOLETE = libdnf.transaction.TransactionItemAction_OBSOLETE
PKG_OBSOLETED = libdnf.transaction.TransactionItemAction_OBSOLETED
PKG_REINSTALL = libdnf.transaction.TransactionItemAction_REINSTALL
PKG_REINSTALLED = libdnf.transaction.TransactionItemAction_REINSTALLED
PKG_REMOVE = libdnf.transaction.TransactionItemAction_REMOVE
PKG_UPGRADE = libdnf.transaction.TransactionItemAction_UPGRADE
PKG_UPGRADED = libdnf.transaction.TransactionItemAction_UPGRADED

if we poke those, we find that '7' is actually PKG_UPGRADED:

>>> print(dnf.transaction.PKG_UPGRADED)
7

so it seems that we're getting a progress callback for the action 'upgraded', but that action isn't in the callback API. That seems wrong.

I think the commit that caused this was the one that refactored the progress callbacks to use libdnf as part of the near-removal (only an API-fulfilling stub remains, now) of dnf.transaction, this one:

https://github.com/rpm-software-management/dnf/commit/8198019c0

Comment 1 Adam Williamson 2018-09-18 04:00:16 UTC
For the record, I checked and it doesn't seem like there's any chance this could crash anaconda or lorax in any circumstance. anaconda's and lorax's approach to the callbacks is to handle ones with specific actions and ignore others; dnfdragora/dnfdaemon sort of assumed that they knew *all* possible actions (because they handled all the ones documented in the docs and API...) and the code actually crashes if it runs into an undocumented one.

I don't know what other important components may be tripped up by this, if any.

Comment 3 Ben Cotton 2019-08-13 16:48:51 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 4 Fedora Update System 2019-08-14 12:11:12 UTC
FEDORA-2019-40235845dc has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-40235845dc

Comment 5 Fedora Update System 2019-08-16 19:50:19 UTC
dnf-4.2.8-1.fc30, dnf-plugins-core-4.0.9-1.fc30, dnf-plugins-extras-4.0.5-1.fc30, libdnf-0.35.2-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-40235845dc

Comment 6 Fedora Update System 2019-08-26 13:26:25 UTC
FEDORA-2019-40235845dc has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-40235845dc

Comment 7 Fedora Update System 2019-08-27 18:21:24 UTC
dnf-4.2.8-1.fc30, dnf-plugins-core-4.0.9-1.fc30, dnf-plugins-extras-4.0.5-1.fc30, libdnf-0.35.2-1.fc30, swid-tools-0.8.6-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-40235845dc

Comment 8 Fedora Update System 2019-08-29 05:05:20 UTC
FEDORA-2019-40235845dc has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-40235845dc

Comment 9 Fedora Update System 2019-08-30 00:03:35 UTC
dnf-4.2.8-1.fc30, dnf-plugins-core-4.0.9-1.fc30, libdnf-0.35.2-1.fc30, swid-tools-0.8.6-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-40235845dc

Comment 10 Fedora Update System 2019-09-06 12:30:59 UTC
dnf-4.2.8-1.fc30, dnf-plugins-core-4.0.9-1.fc30, libdnf-0.35.2-1.fc30, swid-tools-0.8.6-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.