Bug 2142665

Summary: Can't Enable Repositories After Upgrading from 6.9 When Download Policy was Set to Background
Product: Red Hat Satellite Reporter: myoder
Component: RepositoriesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.11.4CC: iballou, paji
Target Milestone: UnspecifiedKeywords: Triaged, Upgrades
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: 2023-12-22 17:35:57 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 myoder 2022-11-14 19:43:22 UTC
Description of problem:

On a 6.11.4 Satellite, the "Default Red Hat Repository download policy" setting was configured to "background".  This option no longer exists (was last used in 6.9), and the only 2 options should be "immediate" and "on_demand".  When Satellite has "background" configured for this option in 6.11.4, users can no longer enable repositories from "Content => Repositories" (or via hammer commands).  Any attempt is met with the error "root_id violates not-null constraint".

Have not confirmed, but it seems likely the "background" option was set in 6.9, and after upgrading to 6.10 then to 6.11, this setting was still configured within Satellite's "Administer => Settings" page under the "Content" tab.


With the "background" option set, we see the api call to enable the repository:

~~~
2022-11-12T23:26:41 [I|app|d647bf64] Started PUT "/katello/api/products/38/repository_sets/11412/enable" for 10.22.0.13 at 2022-11-12 23:26:41 +0300
~~~

Then we see the Satellite reaching out to the CDN for repomd.xml file (which it grabs successfully):

~~~
2022-11-12T23:26:41 [I|app|d647bf64] CDN: Requesting path https://cdn.redhat.com:443/content/dist/layered/rhel8/x86_64/openstack/16.2/os/repodata/repomd.xml
~~~

And finally we get a "root_id" violates not-null constraint (where we see the root_id, remote_href, publication_href and version_href are all null when we try to populate the katello_repositories table):

~~~
2022-11-12T23:26:48 [E|bac|d647bf64] PG::NotNullViolation: ERROR:  null value in column "root_id" violates not-null constraint
 d647bf64 | DETAIL:  Failing row contains (2370, 1fa9496f-7305-4f6a-b5cc-42df61a0565b, null, 1, Default_Organization/Library/content/dist/layered/rhel8/x86_64/openstac..., 1, null, null, null, null, null, null, null, null, null, null, null, 1970-01-01 00:00:00, 1970-01-01 00:00:00, 1970-01-01 00:00:00).
~~~


Using the sql debugging option, we see that Satellite fails to create a katello_root_repositories entry for the repository we are trying to enable, which explains why "root_id" is null.

Version-Release number of selected component (if applicable):
Discovered on 6.11.4, but presumably it is affected by any system that has upgraded from 6.9, while having the "background" option set on 6.9.

How reproducible:
have not reproduced yet, but will setup up a reproducer to test the theory to reproduce it.

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
After changing the setting for "Default Red Hat Repository download policy" to "on_demand", this setting changed back to "background" 3 times.  Not sure what triggered Satellite to change it back to "background".  The logs don't show any indication of the "background" option being present, or being changed back.  
But after the setting was changed to "on_demand" admin user was allowed to enable a repository.  Upon trying to enable a second repository, we observed the same error "root_id violates not-null constraint" and confirmed the "background" option had been reverted.  It took 4 times to change it to "on_demand" and presumably this option has stayed.  Will need to confirm the option has not reverted back to "background".

Comment 3 Ian Ballou 2023-04-25 19:42:53 UTC
This BZ (https://bugzilla.redhat.com/show_bug.cgi?id=1996136) should've fixed any issues with the background download policy from 6.9 to 6.10.

We'll need to reproduce this this a 6.9->6.10 migration run to see if it's reproducible. If it's not I'll recommend closing the BZ unless the same error as above shows up again.

Comment 5 myoder 2023-12-22 17:36:54 UTC

*** This bug has been marked as a duplicate of bug 1996136 ***