RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2003777 - Show available orgs before prompting for input in syspurpose subcommands
Summary: Show available orgs before prompting for input in syspurpose subcommands
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: subscription-manager
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: rc
: 9.0
Assignee: mhorky
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks: 2037901
TreeView+ depends on / blocked
 
Reported: 2021-09-13 16:54 UTC by mhorky
Modified: 2022-05-17 16:29 UTC (History)
4 users (show)

Fixed In Version: subscription-manager-1.29.21-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2037901 (view as bug list)
Environment:
Last Closed: 2022-05-17 15:58:12 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 2796 0 None Merged 2003777: Show available organizations before asking for input 2021-10-05 13:45:28 UTC
Github candlepin subscription-manager pull 2819 0 None Merged 2003777: Only hint organizations if it's needed 2021-10-06 09:16:31 UTC
Github candlepin subscription-manager pull 2850 0 None Merged 2003777: Fix organizations hint in syspurpose commands 2021-11-03 20:03:19 UTC
Red Hat Issue Tracker ENT-4316 0 None None None 2021-09-13 16:54:37 UTC
Red Hat Issue Tracker RHELPLAN-97021 0 None None None 2021-09-13 16:58:03 UTC
Red Hat Product Errata RHBA-2022:3984 0 None None None 2022-05-17 15:58:22 UTC

Description mhorky 2021-09-13 16:54:37 UTC
Description of problem:
When the user has multiple organizations available, running "subscription-manager syspurpose role --list" prompts for an organization. But no information about available organizations is shown.

The proposal is to show available organizations before the user is asked to enter one.

Steps to Reproduce:
1. (When unregistered, run the following with credentials of a user in multiple organizations)
$ subscription-manager role --list --username <username> --password <password>
Organization: 

Actual results:
(No organizations are shown)

Expected results:
(A list of available organizations is shown)

Additional info:
$ subscription-manager version
subscription management server: 4.1.5-1
subscription management rules: 5.43
subscription-manager: 1.29.18-1.fc34

Comment 1 Jiri Hnidek 2021-09-14 13:51:41 UTC
Hint: the list of available organization printed during registration was implemented in this PR: https://github.com/candlepin/subscription-manager/pull/2221

Comment 2 John Sefler 2021-10-01 18:51:40 UTC
Pretesting...
[root@kvm-02-guest23 ~]# rpm -q subscription-manager
subscription-manager-1.29.19-1.git.24.e45b1f2.el9.x86_64
[root@kvm-02-guest23 ~]# 
[root@kvm-02-guest23 ~]# rpm -q subscription-manager --changelog | grep 2003777
- 2003777: Show available organizations before asking for input

_____________________________________________
SCENARIO 1:
[root@kvm-02-guest23 ~]# subscription-manager syspurpose role --list --username=testuser1 --org=admin
Password: 
Hint: User "testuser1" is member of following organizations: snowwhite, admin
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - SP Starter
 - SP Server
[root@kvm-02-guest23 ~]# 

FAILEDQA: I correctly passed a valid org.  The Hint should have been suppressed.
When a valid org is passed through the options and the username/password/org resolve to one possible consumer, then there is no need for the Hint.


_____________________________________________
SCENARIO 2:
[root@kvm-02-guest23 ~]# subscription-manager syspurpose role --list --username=testuser1 --org=INVALID
Password: 
Hint: User "testuser1" is member of following organizations: snowwhite, admin
Organization with id INVALID could not be found. (HTTP error code 404: Not Found)
[root@kvm-02-guest23 ~]# 

FAILEDQA: I passed a value for org and the Hint is too late.


__________________________________________________________________________________
__________________________________________________________________________________

In my opinion, the Hint should only be presented prior to an interactive org prompting (when multiple orgs are possible).
My suggested behavior will the behavior from other modules (e.g. register) that also present a Hint for org when necessary.  For example:

[root@kvm-02-guest23 ~]# subscription-manager register --username=testuser1 --org=admin
Registering to: rhsm-auto90-candlepin.usersys.redhat.com:8443/candlepin
Password: 
The system has been registered with ID: 8c86b480-edb8-4fef-87dd-84471df63356
The registered system name is: kvm-02-guest23.hv2.lab.eng.bos.redhat.com
[root@kvm-02-guest23 ~]# 
^^^^ NOTICE NO HINT

[root@kvm-02-guest23 ~]# subscription-manager register --username=testuser1 --org=INVALID
Registering to: rhsm-auto90-candlepin.usersys.redhat.com:8443/candlepin
Password: 
Invalid Credentials (HTTP error code 401: Unauthorized)
[root@kvm-02-guest23 ~]# 
^^^^ NOTICE NO HINT

[root@kvm-02-guest23 ~]# subscription-manager register --username=testuser1
Registering to: rhsm-auto90-candlepin.usersys.redhat.com:8443/candlepin
Password: 
Hint: User "testuser1" is member of following organizations: snowwhite, admin
Organization: admin
The system has been registered with ID: 9c2a0380-b786-4f15-ad09-791c87094ec6
The registered system name is: kvm-02-guest23.hv2.lab.eng.bos.redhat.com
[root@kvm-02-guest23 ~]# 
^^^^ NOTICE THE HINT IS ONLY PRESENTED PRIOR TO AN INTERACTIVE PROMPTING FOR AN ORG.

Comment 4 John Sefler 2021-10-11 16:46:11 UTC
Pretesting...

[root@rhsm-auto90-client1 ~]# rpm -q subscription-manager
subscription-manager-1.29.19-1.git.26.ab76b02.el9.x86_64

This build includes "2003777: Only hint organizations if it's needed" main commit ab76b029d9cad5fdff8c36f68b9e6517b9033e19


[root@rhsm-auto90-client1 ~]# subscription-manager role --list --username=testuser1 --password=password --org=admin
Organization with id None could not be found. (HTTP error code 404: Not Found)    <=========== DID NOT EXPECT THIS
[root@rhsm-auto90-client1 ~]# 
[root@rhsm-auto90-client1 ~]# tail -f /var/log/rhsm/rhsm.log 
2021-10-11 12:39:27,057 [DEBUG] subscription-manager:2666183:MainThread @cli.py:189 - Consumer Identity name=None uuid=None
2021-10-11 12:39:27,057 [DEBUG] subscription-manager:2666183:MainThread @connection.py:717 - Making request: GET /candlepin/users/testuser1/owners
2021-10-11 12:39:27,065 [DEBUG] subscription-manager:2666183:MainThread @connection.py:571 - Loaded CA certificates from /etc/rhsm/ca/: rhsm-auto90-candlepin.pem, timeout_listener.pem, redhat-entitlement-authority.pem, redhat-uep.pem
2021-10-11 12:39:27,109 [DEBUG] subscription-manager:2666183:MainThread @connection.py:810 - Response time: 0.015153884887695312, Smoothed response time: 0.015153884887695312
2021-10-11 12:39:27,109 [DEBUG] subscription-manager:2666183:MainThread @connection.py:787 - Response: status=200, requestUuid=0d6bee8c-05d5-4e13-acb9-a6feb51ff8b3, request="GET /candlepin/users/testuser1/owners"
2021-10-11 12:39:27,111 [DEBUG] subscription-manager:2666183:MainThread @connection.py:717 - Making request: GET /candlepin/owners/None/system_purpose
2021-10-11 12:39:27,117 [DEBUG] subscription-manager:2666183:MainThread @connection.py:571 - Loaded CA certificates from /etc/rhsm/ca/: rhsm-auto90-candlepin.pem, timeout_listener.pem, redhat-entitlement-authority.pem, redhat-uep.pem
2021-10-11 12:39:27,149 [DEBUG] subscription-manager:2666183:MainThread @connection.py:810 - Response time: 0.010170459747314453, Smoothed response time: 0.014655542373657227
2021-10-11 12:39:27,149 [DEBUG] subscription-manager:2666183:MainThread @connection.py:787 - Response: status=404, requestUuid=4f4ae156-58a7-4a5f-85a3-3360b384356b, request="GET /candlepin/owners/None/system_purpose"
2021-10-11 12:39:27,150 [WARNING] subscription-manager:2666183:MainThread @abstract_syspurpose.py:190 - Unable to get list of valid fields using REST API: HTTP error (404 - Not Found): Organization with id None could not be found.


FailedQA: There appears to be an exception handling problem when making this call from an unregistered state.

Comment 5 John Sefler 2021-10-11 16:49:34 UTC
In the comment above, I should have noted that the response is the same with|without making the call from the syspurpose subcommand...

[root@rhsm-auto90-client1 ~]# subscription-manager role --list --username=testuser1 --password=password --org=admin
Organization with id None could not be found. (HTTP error code 404: Not Found)
[root@rhsm-auto90-client1 ~]# subscription-manager syspurpose role --list --username=testuser1 --password=password --org=admin
Organization with id None could not be found. (HTTP error code 404: Not Found)
[root@rhsm-auto90-client1 ~]#

Comment 6 John Sefler 2021-11-11 20:20:57 UTC
Pretesting after applying all three pull requests...
  https://github.com/candlepin/subscription-manager/pull/2796
  https://github.com/candlepin/subscription-manager/pull/2819
  https://github.com/candlepin/subscription-manager/pull/2850

[root@kvm-04-guest08 ~]# rpm -q subscription-manager
subscription-manager-1.29.19-1.git.119.033bf98.el9.x86_64

[root@kvm-04-guest08 ~]# subscription-manager syspurpose role --list --username=testuser1 --org=admin
Error: you must register or specify --username and --password to list role

[root@kvm-04-guest08 ~]# subscription-manager syspurpose role --list --username=testuser1 --org=admin --password=password
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - SP Starter
 - SP Server

[root@kvm-04-guest08 ~]# subscription-manager syspurpose role --list --username=testuser1 --org=INVALID
Error: you must register or specify --username and --password to list role

[root@kvm-04-guest08 ~]# subscription-manager syspurpose role --list --username=testuser1 --org=INVALID --password=password
Organization with id INVALID could not be found. (HTTP error code 404: Not Found)

[root@kvm-04-guest08 ~]# subscription-manager role --list --username=testuser1 --password=password
Hint: User "testuser1" is member of following organizations: snowwhite, admin       <============ PASSED
Organization: INVALID
Organization with id INVALID could not be found. (HTTP error code 404: Not Found)

[root@kvm-04-guest08 ~]# subscription-manager role --list --username=testuser1 --password=password
Hint: User "testuser1" is member of following organizations: snowwhite, admin       <============ PASSED
Organization: admin
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - SP Starter
 - SP Server

[root@kvm-04-guest08 ~]# subscription-manager orgs --username=mickey --password=password
+-------------------------------------------+
          mickey Organizations
+-------------------------------------------+

Name: Donald Duck
Key:  donaldduck

[root@kvm-04-guest08 ~]# subscription-manager role --list --username=mickey --password=password
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - SP Starter
 - SP Server



Verified:Tested  syspurpose shows available orgs (when needed) before prompting for an org

Comment 12 errata-xmlrpc 2022-05-17 15:58:12 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 (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


Note You need to log in before you can comment on or make changes to this bug.