Bug 1947958

Summary: DNF no longer raises an error when an unknown group is installed
Product: Red Hat Enterprise Linux 8 Reporter: Brian Lane <bcl>
Component: dnfAssignee: Lukáš Hrázký <lhrazky>
Status: CLOSED ERRATA QA Contact: Tomáš Bajer <tbajer>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 8.4CC: amatej, cbesson, james.antill, lhrazky, pkratoch, tbajer
Target Milestone: betaKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.7.0-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:23:43 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:
Bug Depends On: 2006661    
Bug Blocks:    
Attachments:
Description Flags
Simple python reproducer none

Description Brian Lane 2021-04-09 15:36:22 UTC
Created attachment 1770671 [details]
Simple python reproducer

Description of problem:
dnf-4.4.2-2 no longer raises an error when using group_install() with an unknown group.

Older versions used to raise dnf.exceptions.MarkingError, and in RHEL 8.3 with dnf-4.2.23-4 it started raising a plain ValueError (see bug #1943206)


Version-Release number of selected component (if applicable):
dnf-4.4.2-2 

How reproducible:
always

Steps to Reproduce:
1. Run attached reproducer and observe output


[root@localhost ~]# rpm -q dnf
dnf-4.4.2-11.el8.noarch
[root@localhost ~]# ./1943206.py 
Group id 'base' does not exist, skipping.
OK: Installed 'base' group
Group id 'unknown' does not exist, skipping.
ERROR: Should have been traceback for 'unknown' group

Comment 1 Lukáš Hrázký 2021-04-13 13:54:56 UTC
Well, apologies for the mess. This was changed here: https://github.com/rpm-software-management/dnf/commit/f54a1001eb4eefda952de522902c2dd18527023f

In an attempt to bring some sanity to the code, but unfortunately installation of both groups and environments goes through this wrapper which just eats the exception (and prints the warning): https://github.com/rpm-software-management/dnf/blob/395541fbf8f87f81cdca7567f22be1182e55bea7/dnf/comps.py#L94

It's a bad interface which we maintained for compatibility. To fix this we either need to break the interface or add a new one (or revert to the previous inconsistent behavior, which seems like the worst option).

(FTR I haven't yet managed to find where the MarkingError -> ValueError change happened)

Jaroslav, can you propose a solution? IIRC I wanted to not catch the exception, if we did that, at least now lorax would have something to catch, this way it's still not working correctly.

Comment 2 Lukáš Hrázký 2021-07-20 13:44:16 UTC
PR: https://github.com/rpm-software-management/dnf/pull/1784

With the above, dnf will start throwing CompsError when a group or environment is not found for the install methods.

Comment 3 Lukáš Hrázký 2021-07-22 15:58:17 UTC
Brian, we've discussed this in the team and concluded raising a CompsError (admittedly yet another exception class than what was thrown before) is the best way to move forward here. Not raising any exception is clearly a bug and ValueError is also not the right exception to raise.

Is this fine with you, assuming you'll have to add another except block for catching this one?

Right now this bug is slated for 8.5, but that now depends mainly on the API users being able to adapt to this API change for 8.5, so it may well need to be pushed to 8.6.

Again, apologies for the inconvenience...

Comment 4 Brian Lane 2021-07-22 17:56:05 UTC
(In reply to Lukáš Hrázký from comment #3)
> Brian, we've discussed this in the team and concluded raising a CompsError
> (admittedly yet another exception class than what was thrown before) is the
> best way to move forward here. Not raising any exception is clearly a bug
> and ValueError is also not the right exception to raise.
> 
> Is this fine with you, assuming you'll have to add another except block for
> catching this one?
> 
> Right now this bug is slated for 8.5, but that now depends mainly on the API
> users being able to adapt to this API change for 8.5, so it may well need to
> be pushed to 8.6.
> 
> Again, apologies for the inconvenience...

That sounds fine, I can catch multiple exceptions to cover all the cases if I need to :)

Comment 5 Lukáš Hrázký 2021-09-06 13:57:27 UTC
Ok, thanks Brian, this bug has been moved to 8.6. Can you add the catch for CompsError into lorax for 8.6, so that we can merge this upstream and schedule it for 8.6 release? Thanks!

Comment 6 Brian Lane 2021-09-07 17:28:52 UTC
(In reply to Lukáš Hrázký from comment #5)
> Ok, thanks Brian, this bug has been moved to 8.6. Can you add the catch for
> CompsError into lorax for 8.6, so that we can merge this upstream and
> schedule it for 8.6 release? Thanks!

Sure, once this has acks I can push it as Related to this bug.

Comment 7 Lukáš Hrázký 2021-10-11 13:20:29 UTC
Brian, the acks are in, can you make the change (unless it's been done already)? We should move forward with this in a timely manner. Thanks!

Comment 8 Brian Lane 2021-10-11 17:31:56 UTC
I have a PR here - https://github.com/weldr/lorax/pull/1179

Note that this bug needs to have ITR set before it will turn on release+ and allow commits.

Comment 9 Lukáš Hrázký 2021-10-12 09:28:08 UTC
Acceptation Criteria:
The Base.group_install() and Base.environment_install() methods raise an exception of type dnf.exceptions.CompsError in case the group or environment doesn't exist.

Comment 11 Lukáš Hrázký 2021-10-15 11:31:58 UTC
Ok, the release+ is there, Brian!

We are also planning to add a conflict on lorax versions lower than the one with this fix to dnf so that we force the upgrade and don't allow a broken combination of versions. Can you let me know the version in which the fix will land? Thank you.

Comment 12 Brian Lane 2021-10-15 16:02:17 UTC
(In reply to Lukáš Hrázký from comment #11)
> Ok, the release+ is there, Brian!
> 
> We are also planning to add a conflict on lorax versions lower than the one
> with this fix to dnf so that we force the upgrade and don't allow a broken
> combination of versions. Can you let me know the version in which the fix
> will land? Thank you.

That doesn't seem like the right thing to do, dnf should not be obsoleting any version of a package that uses it.

This new version of lorax will handle all the variations of this error, so I don't think there is anything for dnf to do.
Also, this change is in a disused corner of lorax, the chances of someone hitting it are very low at this point since they should all be using osbuild-composer anyway.

Comment 13 Lukáš Hrázký 2021-10-18 08:18:42 UTC
(In reply to Brian Lane from comment #12)
> That doesn't seem like the right thing to do, dnf should not be obsoleting
> any version of a package that uses it.
> 
> This new version of lorax will handle all the variations of this error, so I
> don't think there is anything for dnf to do.

No, not obsoleting, conflicting:

Assume dnf-1 didn't raise CompsError and dnf-2 does.
lorax-1 doesn't catch CompsError (it tracebacks) and lorax-2 does handle CompsError gracefully.

We would add in dnf.spec:
Conflicts: lorax < 2

So that you can't upgrade dnf to version 2 and keep lorax at 1, which would mean lorax now can crash on a non-existent group.


Tbf. I'm not a personal fan of this just because it adds a relation between dnf and lorax in the opposite direction (lorax depends on dnf, now dnf references lorax in its .spec and from dnf's standpoint it's a bit arbitrary), but it is the proper way to prevent the described breakage in the rpm packaging system it would seem.

> Also, this change is in a disused corner of lorax, the chances of someone
> hitting it are very low at this point since they should all be using
> osbuild-composer anyway.

That might be an argument to not add the conflict just because the case is so niche now.

Comment 14 Brian Lane 2021-10-18 16:07:37 UTC
(In reply to Lukáš Hrázký from comment #13)
> (In reply to Brian Lane from comment #12)
> > That doesn't seem like the right thing to do, dnf should not be obsoleting
> > any version of a package that uses it.
> > 
> > This new version of lorax will handle all the variations of this error, so I
> > don't think there is anything for dnf to do.
> 
> No, not obsoleting, conflicting:
> 
> Assume dnf-1 didn't raise CompsError and dnf-2 does.
> lorax-1 doesn't catch CompsError (it tracebacks) and lorax-2 does handle
> CompsError gracefully.
> 
> We would add in dnf.spec:
> Conflicts: lorax < 2
> 
> So that you can't upgrade dnf to version 2 and keep lorax at 1, which would
> mean lorax now can crash on a non-existent group.
> 
> 
> Tbf. I'm not a personal fan of this just because it adds a relation between
> dnf and lorax in the opposite direction (lorax depends on dnf, now dnf
> references lorax in its .spec and from dnf's standpoint it's a bit
> arbitrary), but it is the proper way to prevent the described breakage in
> the rpm packaging system it would seem.

Yeah, that just seems wrong to me. If anything lorax could add a requirement on the newer version of dnf after it is built.

> 
> > Also, this change is in a disused corner of lorax, the chances of someone
> > hitting it are very low at this point since they should all be using
> > osbuild-composer anyway.
> 
> That might be an argument to not add the conflict just because the case is
> so niche now.

I can agree to that :) It really is code that is only hit during testing, so I really don't want to see anything referring to lorax added to dnf.

Comment 15 Jaroslav Mracek 2021-10-20 11:34:33 UTC
Ok, we will not create a conflict.

Comment 23 errata-xmlrpc 2022-05-10 15:23:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dnf bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2051