Bug 2223415

Summary: Force registering from a Capsule to the Satellite using global registration template fails with HTTP error code 422: Unprocessable Entity error
Product: Red Hat Satellite Reporter: Manu Sunil <msunil>
Component: RegistrationAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.14.0CC: ahumbe, lstejska, nalfassi, rlavi
Target Milestone: UnspecifiedKeywords: 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: 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 Manu Sunil 2023-07-17 18:09:42 UTC
Description of problem:

- Force registering from a Capsule to the Satellite using global registration template fails with HTTP error code 422: Unprocessable Entity error.

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

- satellite-6.14.0-3.el8sat.noarch

How reproducible:

- Only when the capsule registered to originally does not have the Lifecycle Environments associated. 

Steps to Reproduce:

1. Deploy a Capsule

2. Capsule should not be associated with any lifecycles.

3. Register client to the Capsule using global registration template.

   The registration will report the following message but will be successful even though yum repositories reports 404.

   ~~~
   Validation failed: Content view environment content facets is invalid (HTTP error code 422: Unprocessable Entity)
   ~~~

   ~~~
   8  | client.example.com  | RedHat 8.7       |            | 10.10.180.1 | 92:fa:8c:47:dc:b9 | Warning       |              |                      
   ~~~

   ~~~
   Errors during downloading metadata for repository 'rhel-8-for-x86_64-baseos-rpms':
   - Status code: 404 for https://capsule.example.com/pulp/content/RedHat/Library/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml (IP: 10.10.125.2)
   Error: Failed to download metadata for repo 'rhel-8-for-x86_64-baseos-rpms': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
   ~~~

4. Now, try to force register the client to Satellite using global registration template by using the Force option.


Actual results:

- The script unregisters the client successfully.

  ~~~
  Unregistering from: capsule.example.com:443/rhsm
  System has been unregistered.
  ~~~

  After this, it fails with following message. 

  ~~~
  Validation failed: Host client.example.com: Cannot add content view environment to content facet. The host's content source 'capsule.example.com' does not sync lifecycle environment 'Library'. (HTTP error code 422: Unprocessable Entity)
  ~~~

- Client can only be registered after removing the profile from the Satellite manually.


Expected results:

- Client should be re-registered to the Satellite. 

Additional info:

- This behavior is not present on 6.13. Force option can be used to register from Capsule to Satellite on 6.13.

Comment 1 Leos Stejskal 2023-07-18 11:41:33 UTC
> Capsule should not be associated with any lifecycles.

Why? Because of this registration is failing due to an error coming from RHEL:
>   Errors during downloading metadata for repository 'rhel-8-for-x86_64-baseos-rpms':
>   - Status code: 404 for https://capsule.example.com/pulp/content/RedHat/Library/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml (IP: 10.10.125.2)
>   Error: Failed to download metadata for repo 'rhel-8-for-x86_64-baseos-rpms': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

This is not an issue in registration, but in not existing repository on capsule.

> This behavior is not present on 6.13.
Really? Do you have an environment where can I confirm it? From my understanding
registering to capsule without env/cv never worked before.

Comment 2 Manu Sunil 2023-07-18 12:02:23 UTC
Hello Leos,

The issue is not with the registration to the Capsule. Yes, it is expected that we get 404 error when when LCEs are not properly associated with the capsules.

The issue is when I try to re-register using the Force option on GRT to the Satellite after the above process.

For example, If I mistakenly choose a capsule without the correct lifecycle. The registration completes with `Validation failed` message and gives the 404 error(as expected).
Now, if I try to re-register the client to Satellite by generating a global registration script with Force(after changing the capsule option), it reports the 422 error.

Apologies, I don't have the setup readily available. I can reproduce the issue once again and share the setup here.

Regards,
Manu Sunil

Comment 4 Leos Stejskal 2023-08-01 05:58:30 UTC
I see. On that second capsule, is the Library environment synced there? See the error:

> Validation failed: Host client.example.com: Cannot add content view environment to content facet. The host's content source 'capsule.example.com' does not sync the lifecycle environment 'Library'. (HTTP error code 422: Unprocessable Entity)

Looks like you selected a capsule and environment which is not synced there. Try to remove the environment from the command and run it again.