Bug 1921453

Summary: Global Registration: page generate command without Satellite or capsule hostname
Product: Red Hat Satellite Reporter: Ashfaqur Rahaman <arahaman>
Component: RegistrationAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Stephen Wadeley <swadeley>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.9.0CC: ahumbe, lstejska, sraut, swadeley
Target Milestone: 6.10.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 14:09:54 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 Ashfaqur Rahaman 2021-01-28 02:20:28 UTC
Description of problem:
In Global Registration page if we do not select Capsule and generate the command, it generates the command with Satellite IP 

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


How reproducible:
Always

Steps to Reproduce:
1. In global registration page, Select "Operating System" as Ubuntu
2. Do not select any Capsule
3. Generate Command 

Actual results:

the url generated with satellite IP: 

----
curl -X GET "https://10.71.133.16/register?location_id=2&operatingsystem_id=2&organization_id=1" -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MTE4MDAxNDEsImp0aSI6IjNhYjNhYmJiNzNmZmI4YmJiMGZmODE5ZDk3OTIyOGVlZjU0ZmVhMTU2NDU5OGEwNGYxYTJlMWMwODA2YjExZjEiLCJleHAiOjE2MTE4MTQ1NDF9.9B5ldgHdua--hZ826dQh-n1Qj840Yy1HBwEDiAUTmgE' | bash
----

After selecting the capsule : 
----
curl -X GET "https://sat69.apac-mps.anzlab.bne.redhat.com:9090/register?location_id=2&operatingsystem_id=2&organization_id=1" -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MTE4MDAxNjIsImp0aSI6IjY0ZmY4ZTBhMDYyMTM1YmYyM2RmNmYxMTk1MmNjOTQ3OTE2ZmEzNTkwZmIxZjZkODMzMjk4MDFhNWUxOTM2MjMiLCJleHAiOjE2MTE4MTQ1NjJ9.Z6QtK78tC4r2nS7X1Vl6OPup1UflzfFYysSxycfSIbA' | bash
----

Expected results:
1. It must check and if the field is blank it should give notification that no capsule has selected and force user to select one

2. If there is only 1 Satellite/capsule it should select the one by default. 


Additional info:
n/a

Comment 1 Ashfaqur Rahaman 2021-01-28 02:28:20 UTC
Attempting to register failing with below error: 

----
# curl -X GET --insecure "https://10.71.133.16/register?location_id=2&operatingsystem_id=3&organization_id=1" -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MTE4MDA2NDgsImp0aSI6IjI5NGUzNDg0OTU2OGRiNzFmZTU1OTBhYTEwYWM2ZWVmYmZjOTA3Y2E0OGMxN2M1ZDljNjU5OTdkOTdiNWYyNDgiLCJleHAiOjE2MTE4MTUwNDh9._QznlxLsTvXcHl6YwiWeKyI3I2GtZ0LJ5x_yLtfhAtc' | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10267    0 10267    0     0  27378      0 --:--:-- --:--:-- --:--:-- 27451
#
# Running registration
#
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL: no alternative certificate subject name matches target host name '10.71.133.16'
More details here: https://curl.haxx.se/docs/sslcerts.html
-----

It works when I tried with hostname. 

~~~~~~
[root@localhost ~]# curl -X GET --insecure "https://sat69.apac-mps.anzlab.bne.redhat.com:9090/register?location_id=2&operatingsystem_id=3&organization_id=1" -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MTE4MDA3ODIsImp0aSI6ImU1ZWUxZWYzZThhYjM3YTJiY2U5MTYzNTZmZDBkZDdmNmFjZDZlNWQwOGU1YjI0MTlhZjFjNmY1MDFkMzAxMWQiLCJleHAiOjE2MTE4MTUxODJ9.ozZrm4jQa1jNolZ9T7Ph7vxBAuBza4Phb_qAki9NJIQ' | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10349  100 10349    0     0  21077      0 --:--:-- --:--:-- --:--:-- 21077
#
# Running registration
#
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10678  100 10549  100   129  13898    169 --:--:-- --:--:-- --:--:-- 14068
/usr/sbin/restorecon
Relabeled /root/.ssh from unconfined_u:object_r:ssh_home_t:s0 to system_u:object_r:ssh_home_t:s0
Relabeled /root/.ssh/authorized_keys from unconfined_u:object_r:ssh_home_t:s0 to system_u:object_r:ssh_home_t:s0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    27  100    27    0     0    245      0 --:--:-- --:--:-- --:--:--   247
Successfully enrolled host localhost with Foreman.
~~~~~~

Comment 2 Leos Stejskal 2021-02-05 11:39:59 UTC
Hi,
this is expected behavior, if you don't select capsule, Satellite's URL is going to be use.
But I guess it would be good idea to tell it user, instead of just showing blank value.
Added to https://projects.theforeman.org/issues/31240

The second issue, with the error "SSL: no alternative certificate subject name matches target host name '10.71.133.16'".
When you generated the registration command, what was the URL of the Satellite in that moment?
Command URL is generated from current URL (& protocol), like this:

- http://satellite.example.com => "curl -X GET http://satellite.example.com/register ..."
- https://satellite.example.com => "curl -X GET https://satellite.example.com/register ..."
- http://1.1.1.1 => "curl -X GET http://1.1.1.1/register ..."
- https://1.1.1.1 => "curl -X GET https://1.1.1.1/register ..."

I would say its expected behavior and users should not access Satellite by IP but rather by domain name,
but I'll look think about it and discuss it with the team.

Comment 3 Stephen Wadeley 2021-02-11 12:07:44 UTC
Hello Leos


We can ask DocsTeam to not state that step is optional, as docs currently does.

Connecting using FQDN (not IP or shortname) is stated in docs.

Thank you

Comment 4 Stephen Wadeley 2021-02-11 14:49:24 UTC
(In reply to Stephen Wadeley from comment #3)
> Hello Leos
> 
> 
> We can ask DocsTeam to not state that step is optional, as docs currently
> does.
> 
> Connecting using FQDN (not IP or shortname) is stated in docs.
> 
> Thank you

Hello Leos

Please approve or amend these changes:
https://github.com/theforeman/foreman-documentation/pull/386/files

Thank you

Comment 9 Stephen Wadeley 2021-07-14 18:34:33 UTC
(In reply to Stephen Wadeley from comment #4)
> (In reply to Stephen Wadeley from comment #3)
> > Hello Leos
> > 
> > 
> > We can ask DocsTeam to not state that step is optional, as docs currently
> > does.
> > 

Docs [1] now states

From the Capsule list, select the Capsule to register hosts through. You must select the internal Capsule if you do not want to use an external Capsule. 


[1] https://access.redhat.com/documentation/en-us/red_hat_satellite/6.9/html/managing_hosts/registering_hosts#registering-a-host-to-project-using-the-global-registration-template_managing-hosts

Comment 14 errata-xmlrpc 2021-11-16 14:09:54 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 (Moderate: Satellite 6.10 Release), 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/RHSA-2021:4702