Bug 2030101

Summary: No longer be able to import content into disconnected Satellite for existing content views
Product: Red Hat Satellite Reporter: matt jia <mjia>
Component: Inter Satellite SyncAssignee: Partha Aji <paji>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.10.0CC: ahumbe, ajambhul, dhjoshi, gscarbor, kkinge, ltran, mshimura, paji, pcreech, rmynar, sadas, saydas, sbible, vdeshpan, wclark
Target Milestone: 6.11.0Keywords: PrioBumpGSS, Regression, 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:
: 2049760 (view as bug list) Environment:
Last Closed: 2022-07-05 14:30:51 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 matt jia 2021-12-08 02:22:17 UTC
Description of problem:

After upgrading disconnected Satellite, content view import failed on:


Validation failed: Label has already been taken, Name has already been taken (ActiveRecord::RecordInvalid)


This is because the existing content views have import_only set false. 

cat /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/content_view_version/import.rb:

 def self.find_or_create_import_view(organization:, metadata:, library: false)
          if library
            metadata = { name: ::Katello::ContentView::IMPORT_LIBRARY,
                         label: ::Katello::ContentView::IMPORT_LIBRARY,
                         description: "Content View used for importing library"
                        }
          end

          cv = ::Katello::ContentView.find_by(label: metadata[:label],
                                              organization: organization,
                                              import_only: true)
          if cv.blank?
            ::Katello::ContentView.create!(metadata.merge(organization: organization, import_only: true))
          else
            cv.update!(description: cv_metadata[:description]) if cv.description != metadata[:description]
            cv
          end
        end

As you can see, above func is trying to find CV with import_only true. However, all the existing CVs after the upgrade have import_only false. It ends up to re-create the cv.

It seems like we're missing a migration step during the 6.10 upgrade for disconnected Server. To work around the issue, I have to hack the db directly as hammer does not allow me to do with:

[root@xxx]# hammer content-view update  --import-only true --id 56
Could not update the content view:
     Validation failed: Import only Import-only can not be changed after creation

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

6.10


How reproducible:

Easy


Steps to Reproduce:
1. install a disconnected 6.9 Satellite
2. import some CVs to it
3. upgrade both connected and disconnected Satellites to 6.10

4. import a new content view version

Actual results:

The content import failed with Validation failed: Label has already been taken, Name has already been taken

Expected results:

The content import should be successfully.

Additional info:

Comment 1 Partha Aji 2022-01-25 22:27:49 UTC
Connecting redmine issue https://projects.theforeman.org/issues/34314 from this bug

Comment 2 Bryan Kearney 2022-01-28 00:04:49 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34314 has been resolved.

Comment 4 wclark 2022-02-02 00:26:08 UTC
HOTFIX RPM is available for Satellite 6.10.2

OBTAINING THE HOTFIX:

The hotfix RPM is too large to be provided as an attachment on Bugzilla. Therefore please contact Red Hat Support to obtain the hotfix.

INSTALL INSTRUCTIONS:

1. Take a complete backup or snapshot of Satellite 6.10.2 server

2. Obtain the hotfix RPM from Red Hat Support and copy it to Satellite server

3. # yum install ./tfm-rubygem-katello-4.1.1.42-2.HOTFIXRHBZ2030101.el7sat.noarch.rpm --disableplugin=foreman-protector

4. # satellite-maintain service restart

Comment 5 Vedashree Deshpande 2022-02-24 14:12:04 UTC
Hello, 

One of my customers have installed the hotfix and the import is still not happening. He is not seeing any errors but import doesnt seem to have done completely. 

Can someone help here?

Comment 6 Partha Aji 2022-02-24 18:57:37 UTC
I don't see HF comment specifying this but the customer needs to run a rake task on the satellite.
"""
foreman-rake katello:set_content_view_import_only ID=<content-view-id>

"""


This will still not work. 
"""
hammer content-view update  --import-only true --id 56
"""

Comment 8 Lai 2022-04-04 20:45:23 UTC
Steps to reproduce:

1. Spin up 2 satellites: one for connected and one for disconnected.
2. On connected, import manifest, change the download policy of rhel to 'Immediate' in settings
3. Sync a few repos
4. Create a cv and add the repos from step 3
5. Run export for complete version
6. On Disconnected, import manifest and set the CDN configuration to use airgap
7. Set the download policy in 'Settings' to "Immediate"
8. scp the export from the connected satellite to /var/lib/pulp/imports and set permission to chown -R pulp:pulp /var/lib/pulp/imports/<dir>
9. Create a cv with the same name from step 4 and make sure to click "import only" checkbox when creating cv
10.  Run import command

Expected:
Import should be successful.

ActuaL
Import is successful.

note: I also published a new cv version in the connected, re-exported the new version and re-imported the new version in the disconnected.  It was updated accurately.

Verified on 6.11 snap 14

Comment 9 Vedashree Deshpande 2022-04-21 09:24:26 UTC
Hello, 

One of my customers ran below command and fixed the issue,
foreman-rake katello:set_content_view_import_only ID=<content-view-id>

But this invited a new issue it seems. 

Now, he is not able to publish and content views with import_only option. 
The error message is "import-only content views can not be published directly"

Is there a different method or option to publish these Content views?

Comment 10 Partha Aji 2022-05-11 15:43:12 UTC
Vedashree,
That is expected behavior. Import-Only content views can't be published (to ensure consistency on imports). Versions can only be "imported" into it. When you import, a new version is created in the content view. You should be able to promote that version to any environment.

Comment 14 errata-xmlrpc 2022-07-05 14:30:51 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