Bug 2047675

Summary: Getting "404 not found" when publishing a content view
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.10.0CC: aeladawy, jsherril, kkinge, myoder, nshaik, pcreech, pdudley, peter.vreman, pmoravec, rcavalca, risantam, sadas, saydas, vdeshpan, wdr
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.3.0.3-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2059379 (view as bug list) Environment:
Last Closed: 2022-07-05 14:32:26 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 Hao Chang Yu 2022-01-28 09:36:31 UTC
Description of problem:
Getting the following error when publishing a content view:

-----------------------------------------
9: Actions::Pulp3::Repository::SaveVersion (error) [ 3352.43s / 0.74s ] Skip
Error:
PulpRpmClient::ApiError
Error message: the server returns an error HTTP status code: 404 Response headers: {"Date"=>"XXXXXXX", "Server"=>"gunicorn", "Content-Type"=>"application/json", "Vary"=>"Accept,Cookie", "Allow"=>"GET, PUT, PATCH, DELETE, HEAD, OPTIONS", ...<snip>} Response body: {"detail":"Not found."} 
-----------------------------------------

This is because the Composite content view and its component content views are referring to the same repositories in Pulp (See below). Delete the composite content view will delete the referring Pulp repositories. Therefore, it breaks all the component content views.

This only affecting the content views that are migrated to Satellite 6.10 from 6.9. Those newly created in Satellite 6.10 don't have this issue.

-----------------------------------------
foreman-rake console
pp Katello::ContentView.find_by_label("ccv_test").repository_references
[#<Katello::Pulp3::RepositoryReference:0x0000000013f33320
  id: 25,
  repository_href:
   "/pulp/api/v3/repositories/rpm/rpm/eb4ce2fd-1056-4736-976d-9a7d629fa334/", <=========== same
  content_view_id: 17,
  root_repository_id: 2>]

pp Katello::ContentView.find_by_label("cv_test").repository_references
[#<Katello::Pulp3::RepositoryReference:0x0000000013c99f88
  id: 7,
  repository_href:
   "/pulp/api/v3/repositories/rpm/rpm/eb4ce2fd-1056-4736-976d-9a7d629fa334/",  <=========== same
  content_view_id: 2,
  root_repository_id: 2>]
-----------------------------------------

Steps to Reproduce:
1. In Satellite 6.9, create a content view with at least 1 repo. Publish it.
2. Create a composite content view and add the content view you just created to it. Publish it.
3. Follow guide to migrate from pulp 2 to pulp 3.

satellite-maintain content prepare

4. Upgrade to Satellite 6.10.
5. In Satellite 6.10, delete the composite content view.
6. After that publish the content view


Actual results:
404 not found

Expected results:
No error


Additional information
Other composite content views that are having the same repository references will also break.

Comment 1 Peter Vreman 2022-01-31 10:56:30 UTC
I think i hit this issue also
The first weeks after migration the sat6.10+pulp3 was running fine. But now i updated content and published new CVs and updated the CCVs the CCV publishing is broken and if the tasks somehow finished the clients only get 404 to retrieve the metadata.
I do not delete CCVs as a whole. Instead if i have published+promoted CCV-versions then the old versions are nicely cleaned-up if they area not assigned to a LE anymore.

Comment 2 Paul Dudley 2022-02-02 19:38:50 UTC
*** Bug 2049195 has been marked as a duplicate of this bug. ***

Comment 4 Paul Dudley 2022-02-02 23:31:56 UTC
Closing bz 2049195 as a duplicate of this, just noting here that the correct_repostories rake does not solve this issue. As noted there, this rake will clear the repos in foreman that are no longer in Pulp:
~~~
foreman-rake console << EORAKE
Katello::Pulp3::RepositoryReference.all.select do |ref|
  api = Katello::RepositoryTypeManager.repository_types[ref.root_repository.content_type].pulp3_api_class.new(SmartProxy.pulp_primary)
  api.repositories_api.read(ref.repository_href)  
rescue => e
   if e&.code == 404
     ref.destroy
   end
end
EORAKE
~~~

Comment 8 Justin Sherrill 2022-02-10 20:20:09 UTC
Created redmine issue https://projects.theforeman.org/issues/34436 from this bug

Comment 11 Lai 2022-03-01 21:17:36 UTC
I followed the steps outside in the description of the bz for verification.

After upgrade and deleting a ccv, I was able to publish the cv that was in the ccv and it was able to publish successfully.

Verified on 7.0 snap 11 with tfm-rubygem-katello-4.3.0.7-1.el7sat.noarch.

This was tested on rhel7.9.  Can't test this on a rhel8.5 system because sat6.9 is only on rhel7.

Comment 15 errata-xmlrpc 2022-07-05 14:32:26 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.11 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-2022:5498

Comment 17 myoder 2022-09-23 16:12:19 UTC
*** Bug 2079460 has been marked as a duplicate of this bug. ***