Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2166317

Summary: initial-setup registration using activation_key fails with message 'Environment with ID "" could not be found'
Product: Red Hat Enterprise Linux 8 Reporter: Jan Stavel <jstavel>
Component: subscription-managerAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.8CC: ptoscano, redakkan, zpetrace
Target Milestone: rcKeywords: Regression, Triaged
Target Release: 8.8Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.28.36-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-16 09:07:12 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:
Attachments:
Description Flags
error message of a registration action none

Description Jan Stavel 2023-02-01 13:33:24 UTC
Created attachment 1941546 [details]
error message of a registration action

I have tried to register a system using initial-setup-graphical.
I have used an activation_key to do so.

I cannot register the system - the application fails with message:

Unable to register the system
Environment with ID "" could not be found.

Traceback appears in /var/log/rhsm/rhsm.log

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/subscription_manager/gui/registergui.py", line 2000, in _register_consumer
    usage=syspurpose.get('usage')
  File "/usr/lib64/python3.6/site-packages/rhsm/connection.py", line 1209, in registerConsumer
    return self.conn.request_post(url, params, headers=headers)
  File "/usr/lib64/python3.6/site-packages/rhsm/connection.py", line 992, in request_post
    return self._request("POST", method, params, headers=headers)
  File "/usr/lib64/python3.6/site-packages/rhsm/connection.py", line 1022, in _request
    info=info, headers=headers, cert_key_pairs=cert_key_pairs)
  File "/usr/lib64/python3.6/site-packages/rhsm/connection.py", line 870, in _request
    self.validateResponse(result, request_type, handler)
  File "/usr/lib64/python3.6/site-packages/rhsm/connection.py", line 944, in validateResponse
    raise RestlibException(response['status'], error_msg, response.get('headers'))
rhsm.connection.RestlibException: HTTP error (404 - Not Found): Environment with ID "" could not be found.



I have tried to register a system using anaconda. It works.
I have tried to use the latest released RHEL8.7 - a registration fails from the same reason as in RHEL8.8

compose-id of a tested system: RHEL-8.8.0-20230122.0

Steps to reproduce (see https://polarion.engineering.redhat.com/polarion/#/project/RHELSS/workitem?id=RHSS-135522 for details)

prepare an activation key with AutoAttach enabled:
 curl -X POST -H "Content-Type:application/json" -k -u <username>:<password> "https://serverip:port/prefix/owners/<org name>/activation_keys" -d '{"name":"<activation_key_name>","autoAttach":"true"}'

1) enable root access to display - in a gnome-terminal at running VM (as a common user)
    xhost si:localuser:root

2) run an initial-setup-graphical
   ssh HOST
   export DISPLAY=:0
   /usr/libexec/initial-setup/initial-setup-graphical

3) click on System/Subscription Manager
4) click on 'I will use an Activation Key'
5) click on 'Next'
6) fill fields 'Organization'   'Activation Key' and press 'Register'

Note: SCA mode was enabled for the used account.

Comment 2 Pino Toscano 2023-02-02 08:24:08 UTC
Hmm interesting, I don't think we did any changes related to environments recently.

Since you are running initial-setup from a console, can you please enable the debug of the HTTP traffic of subscription-manager?
# env SUBMAN_DEBUG_PRINT_REQUEST=1 \
    SUBMAN_DEBUG_PRINT_REQUEST_HEADER=1 \
    SUBMAN_DEBUG_PRINT_REQUEST_BODY=1 \
    SUBMAN_DEBUG_PRINT_RESPONSE=1 \
    /usr/libexec/initial-setup/initial-setup-graphical &> sub-man.log
(note it is a single command, it is wrapped for readability).
Then please send the resulting "sub-man.log" as it is, so we can check what's going on.

Comment 4 Pino Toscano 2023-02-02 13:52:51 UTC
> "environments": [{"id": ""}]

We send an empty environment when registering, and after a bit of code inspection I'm not sure how it gets there.

I see you are registering to stage; can you please try the same with Hosted?

Comment 5 Pino Toscano 2023-02-09 13:38:08 UTC
Also: my guess here is that this is a regression due to the multi-environment work that was added in RHEL 8.6 and in RHEL 9.x.

Can you please check with:
- RHEL 8.6 -- it will fail in the same way
- RHEL 8.4 -- it should work fine

Comment 6 Jan Stavel 2023-02-09 19:54:10 UTC
I have verified

no error appeared for RHEL-8.4.0-RC-1.3

the same error as above appeared for RHEL-8.6.0-RC-1.1

Comment 7 Pino Toscano 2023-02-14 10:34:29 UTC
Indeed is a regression due to the multi-environments work, and how "if foo" behaves in Python with strings and lists.

Comment 9 Jan Stavel 2023-02-20 10:20:38 UTC
I have verified that the application works well:
- it prints an error message instead of 'Oops' on the bar and getting stuck.

Comment 11 Jan Stavel 2023-02-20 10:38:53 UTC
I have mixed two bugs together - sorry for confusing audience.
This bug has nothing with 'Oops' on a top bar.
The fix I have verified solves a problem with a message 'Environment with ID "" could not be found'.
This message does not appear after I apply the last appended fix.

Comment 14 Zdenek Petracek 2023-02-23 21:01:52 UTC
Verification done on SUBMAN version:
[zpetracek@localhost ~]$ subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 4.2.15-1
subscription management rules: 5.43
subscription-manager: 1.28.36-2.el8

verification PASSED, I'll add an attachment after successful registration using activationkey with auto attach enabled. Additional info:

[zpetracek@localhost ~]$ subscription-manager identity
system identity: 2abc26ed-5dfb-452d-bc73-62d03ec16035
name: localhost.localdomain
org name: 16767941
org ID: 16767941

[zpetracek@localhost ~]$ subscription-manager list
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux for x86_64 Beta
Product ID:     486
Version:        8.8 Beta
Arch:           x86_64
Status:         Subscribed
Status Details: 
Starts:         02/09/2023
Ends:           02/24/2023

Comment 18 errata-xmlrpc 2023-05-16 09:07: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 (subscription-manager 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-2023:2984