Bug 1944710

Summary: Should not be able to assign LE on the client profile which is not synced on the capsule server
Product: Red Hat Satellite Reporter: rakesh kumar <rakumar>
Component: Hosts - ContentAssignee: Jeremy Lenz <jlenz>
Status: CLOSED ERRATA QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: high    
Version: 6.8.0CC: ahumbe, dsinglet, iballou, jlenz, ktordeur, mkalyat, myarboro, osousa, pcreech, rlavi, spusater, vsedmik
Target Milestone: 6.14.0Keywords: PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2218657 (view as bug list) Environment:
Last Closed: 2023-11-08 14:17:34 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 rakesh kumar 2021-03-30 14:18:54 UTC
Description of problem:

Let say, the satellite has 2 lifecycle environment 'Development' and 'Testing', only Development LE is assigned and synced to the capsule. After registering a client through the capsule, I can assign 'Testing' LE to the client system in the content host profile. After that, 'yum repolist' fails with 404 error like below:

~~~~~~~~~~~~~~~
[root@client ~]# yum repolist
Loaded plugins: enabled_repos_upload, package_upload, product-id, search-disabled-repos, subscription-manager
https://capsule.example.com/pulp/repos/RedHat/Development/demo/content/dist/rhel/server/7/7Server/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

https://capsule.example.com/pulp/repos/RedHat/Development/demo/content/dist/rhel/server/7/7Server/x86_64/os/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
repo id                                                                  repo name                                                                               status
rhel-7-server-rpms/x86_64                                                Red Hat Enterprise Linux 7 Server (RPMs)                                                0
repolist: 0
Uploading Enabled Repositories Report
Loaded plugins: product-id, subscription-manager
~~~~~~~~~

We should not be able to assign the LE to the client which is not synced on the capsule or we can have a show proper error message(like 'This LE is not synced on the capsule') when trying to assign LE which is not synced on the capsule.

Version-Release number of selected component (if applicable):
Satellite 6.x

How reproducible:
Always

Steps to Reproduce:
1. Register a client through a capsule
2. Go to client profile in content host page, assign a LE which is not synced on the capsule and select a content view in that LE 
3. Execute below command on the client:
 # subscription-manager refresh
 # yum clean all; yum repolist

Comment 4 Jeremy Lenz 2023-03-16 20:48:52 UTC
We should update the host content view selector to require selection in order:

1. Content source (capsule)
2. LCE
3. Content view

In 6.13 the 'Change Content Source' page already does this. This would just be a matter of updating the 'Edit content view assignment' modal on the content view overview card.

Comment 5 Jeremy Lenz 2023-03-17 15:45:45 UTC
In addition, the LCE and Content view selection should be limited based on what environment is assigned to the selected content source.

Comment 6 Jeremy Lenz 2023-03-17 15:46:47 UTC
*** Bug 2134087 has been marked as a duplicate of this bug. ***

Comment 7 Jeremy Lenz 2023-04-18 20:10:43 UTC
Created redmine issue https://projects.theforeman.org/issues/36316 from this bug

Comment 8 Bryan Kearney 2023-04-19 16:01:46 UTC
Upstream bug assigned to jlenz

Comment 9 Bryan Kearney 2023-04-19 16:01:49 UTC
Upstream bug assigned to jlenz

Comment 11 Bryan Kearney 2023-05-17 16:01:41 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36316 has been resolved.

Comment 12 Ian Ballou 2023-06-06 15:03:48 UTC
This is a defect and not an RFE, so I'm removing the RFE bits.

Comment 18 Vladimír Sedmík 2023-06-29 20:12:47 UTC
Verified in 6.14.0 snap 4

Setup as per comment 0:
1) SAT with multiple organizations and LCEs and CVs in each organization
2) CAPS with only a subset of LCEs and a host registered through it

Results:
1) On Host details page -> Change content source page (through top right kebab), as well as on
2) On Host details page -> Overview tab -> Content view details card -> Edit content view assignment modal:
   - Message that some LCEs were disabled because they are not associated with the host's content source is displayed
   - Only the LCEs associated with the content source can be selected
   - Only CVs inside the selected LCE can be selected
3) On the 'Create Host' page
   - The 'Lifecycle Environment' dropdown is scoped to the selected organization (contains only the organization's LCEs).
4) Attempts to assign LCE not synced on the content source through CLI/API returns appropriate error:
[ERROR 2023-06-29T14:14:20 API] 500 Internal Server Error
[DEBUG 2023-06-29T14:14:20 API] {
    "error" => {
        "message" => "Validation failed: Host rhel8host.redhat.com: Cannot add content view environment to content facet. The host's content source 'capsule.redhat.com' does not sync lifecycle environment 'OWCA-2'."
    }
}
5) Content host page -> bulk action still allows to assign any LCE to the selected host. However, the assignment fails with error and the issue will be tracked by BZ#2218528

Comment 21 errata-xmlrpc 2023-11-08 14:17:34 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 (Important: Satellite 6.14 security and bug fix 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/RHSA-2023:6818