Bug 1984133
| Summary: | subscription-manager repos --enable=REPO --disable=REPO --enable=REPO is failing to win on the last parameter | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | John Sefler <jsefler> |
| Component: | subscription-manager | Assignee: | Pino Toscano <ptoscano> |
| Status: | CLOSED ERRATA | QA Contact: | Red Hat subscription-manager QE Team <rhsm-qe> |
| Severity: | low | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 9.0 | CC: | arpandey, ptoscano, redakkan |
| Target Milestone: | rc | Keywords: | Regression, Triaged |
| Target Release: | 9.0 | Flags: | pm-rhel:
mirror+
|
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | subscription-manager-1.29.21-1.el9 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2022-05-17 15:58:13 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
John Sefler
2021-07-20 18:47:40 UTC
(In reply to John Sefler from comment #0) > I suspect this change was caused by the rhel-9 commit "Replace optparse with > argparse" > https://github.com/candlepin/subscription-manager/commit/ > eef1bb13f8924af9539f98330465c110f2df92b5 Yes, this is indeed the case, and it is due to different functionalities in optparse vs argparse. When adding an option, optparse support passing a callback, i.e. a function that is called for the option & its value. There was a common function for both --enable and --disable, adding all the repositories to a single list with an enable/disable flag, so the order of the repositories is preserved. After the conversion to argparse, there is no callback anymore, as it is not supported (in the same form as provided by optparse) by argparse. Instead, each of --enable and --disable piles its repositories in an own list, and these two lists are combined in a single list with first the repositories to enable, then those to disable. This explains the finding: > Now in RHEL 9, it appears that the "--disable" option wins which is a regression. A proper solution is to implement a custom argparse.Action for --enable and --disable, which should implement the same behaviour (appending to the same list) of the old callback. Additional open question:
> Note that this subtle policy was never documented in the man pages.
Considering that I've seen plenty of examples doing "--disable=* --enable=somerepo" (and I even used it myself), it seems that there is this expectation of order done by --enable & --disable.
Hence, should we explicitly document it? (My personal vote goes to "yes".)
Triaging notes: - this is indeed a regression that we want to fix - we want to explicitly document the ordering of --enable & --disable, as it is something people already rely on pre-verifying on subscription-manager-1.29.21-1.el9.x86_64
reproducing issue :
[root@auto-hv-01-guest04 ~]# rpm -q subscription-manager
subscription-manager-1.29.18-2.el9.x86_64
[root@auto-hv-01-guest04 ~]#
[root@auto-hv-01-guest04 ~]# subscription-manager repos --disable=rhel-9-for-x86_64-rt-beta-rpm --enable= rhel-9-for-x86_64-rt-beta-rpm
Repository 'rhel-9-for-x86_64-rt-beta-rpm' is disabled for this system. <<< sequence of arguments not being honored, repository should be enabled
[root@auto-hv-01-guest04 ~]#
Verifying on subscription-manager-1.29.21-1.el9.x86_64:
[root@auto-hv-01-guest04 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.21-1.el9
[root@auto-hv-01-guest04 ~]# rpm -qa --changelog subscription-manager | grep 1984133
- 1984133: repos: respect order of --enable & --disable (ptoscano)
[root@auto-hv-01-guest04 ~]#
[root@auto-hv-01-guest04 ~]# subscription-manager repos –disable=rhel-9-for-x86_64-rt-beta-rpms --enable=rhel-9-for-x86_64-rt-beta-rpms
Repository 'rhel-9-for-x86_64-rt-beta-rpms' is enabled for this system. <<<<< as expected repository is enabled. PASS
[root@auto-hv-01-guest04 ~]#
[root@auto-hv-01-guest04 ~]# subscription-manager repos --disable=rhel-9-for-x86_64-rt-beta-rpms --enable=rhel-9-for-x86_64-rt-beta-rpms --disable=rhel-9-for-x86_64-rt-beta-rpms
Repository 'rhel-9-for-x86_64-rt-beta-rpms' is disabled for this system. <<<< as expected PASS
[root@auto-hv-01-guest04 ~]#
Additional info:
checking documentation update for same.
[root@auto-hv-01-guest04 ~]# man subscription-manager | grep REPO_ID -A 5
--enable=REPO_ID
Enables the specified repository, which is made available by the content sources identified in the system subscriptions. To enable multiple repositories,
use this argument multiple times. Wild cards * and ? are supported. The repositories enabled by this option and disabled by --disable are processed in the
same order they are specified. <<<< man updated as required
--disable=REPO_ID
Disables the specified repository, which is made available by the content sources identified in the system subscriptions. To disable multiple reposito‐
ries, use this argument multiple times. Wild cards * and ? are supported. The repositories disabled by this option and enabled by --enable are processed
in the same order they are specified. <<<<<<< man updated as required
Verification PASSED
Verifying on :
=============
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.21-1.el9
# rpm -q subscription-manager --changelog | grep 1984133
- 1984133: repos: respect order of --enable & --disable (ptoscano)
# subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 Beta
Status: Subscribed
# subscription-manager repos --disable=rhel-9-for-x86_64-rt-beta-rpms --enable=rhel-9-for-x86_64-rt-beta-rpms
Repository 'rhel-9-for-x86_64-rt-beta-rpms' is enabled for this system. --> PASSED
# subscription-manager repos --disable=rhel-9-for-x86_64-rt-beta-rpms --enable=rhel-9-for-x86_64-rt-beta-rpms --disable=rhel-9-for-x86_64-rt-beta-rpms
Repository 'rhel-9-for-x86_64-rt-beta-rpms' is disabled for this system. --> PASSED
# man subscription-manager | grep REPO_ID -A 5
--enable=REPO_ID
Enables the specified repository, which is made available by the content sources identified in the system subscriptions. To enable multiple repositories,use this argument multiple times. Wild cards * and ? are supported. The repositories enabled by this option and disabled by --disable are processed in the same order they are specified.
--disable=REPO_ID
Disables the specified repository, which is made available by the content sources identified in the system subscriptions. To disable multiple repositories, use this argument multiple times. Wild cards * and ? are supported. The repositories disabled by this option and enabled by --enable are processed in the same order they are specified.
Also the man pages have been updated !!
Moving the bug to Verified!!
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 (new packages: subscription-manager), 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:3984 |