This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2278609 - User with "Content Exporter" role cannot export Library content in Red Hat Satellite 6.14
Summary: User with "Content Exporter" role cannot export Library content in Red Hat Sa...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Users & Roles
Version: 6.14.3
Hardware: x86_64
OS: All
high
high
Target Milestone: stream
Assignee: Sayan Das
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-05-02 10:36 UTC by Sayan Das
Modified: 2024-06-06 17:36 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-06-06 17:36:22 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 37430 0 Normal Ready For Testing Content Exporter role is missing the create_content_views permission 2024-05-09 10:58:55 UTC
Github Katello katello pull 10991 0 None open Fixes #37430 - Added create_content_views permission in Content Expor… 2024-05-09 10:58:55 UTC
Red Hat Issue Tracker   SAT-24884 0 None Migrated None 2024-06-06 17:36:20 UTC
Red Hat Knowledge Base (Solution) 7070899 0 None None None 2024-05-17 14:37:08 UTC

Description Sayan Das 2024-05-02 10:36:35 UTC
Description of problem:

With an admin user, the different types of export processes work just fine.

But when an non-admin user is used for hammer or API authentication and the user as "Content Exporter" role assigned, The content export actions on Library environment is impossible to perform.


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

Satellite 6.14.3


How reproducible:

Easily and 100%

Steps to Reproduce:
1. Install a Satellite 6.14 and enable + sync a very small repo with immediate download policy [ Say satellite clients repo ]

2. Create a user called sat_export and assign it with the "Content Exporter" role

# hammer -u admin -p RedHat1! user info --id 5 --fields login,roles
Login: sat_export
Roles: 
    Content Exporter

3. Edit the hammer config file to use the non-admin user:

# cat .hammer/cli.modules.d/foreman.yml 
:foreman:
  # Credentials. You'll be asked for the interactively if you leave them blank here
  #:username: 'admin'
  #:password: 'RedHat1!'
  :username: 'sat_export'
  :password: 'password@123'

4. Try to export Library environment.



Actual results:


Export attempts:

# hammer content-export complete library --format importable --organization-id 1
Could not export the library:
  422 Unprocessable Entity


# hammer content-export complete library --format importable --organization-id 1 --destination-server disconnected_satellite
Could not export the library:
  422 Unprocessable Entity


# hammer content-export complete library --format syncable --organization-id 1 --destination-server disconnected_satellite
Could not export the library:
  422 Unprocessable Entity


# hammer content-export complete library --format syncable --organization-id 1 
Could not export the library:
  422 Unprocessable Entity


Error in production.log:

~~
2024-05-02T15:17:36 [I|app|c3dadce9] Started POST "/katello/api/content_exports/library" for 10.10.1.5 at 2024-05-02 15:17:36 +0530
2024-05-02T15:17:36 [I|app|c3dadce9] Processing by Katello::Api::V2::ContentExportsController#library as */*
2024-05-02T15:17:36 [I|app|c3dadce9]   Parameters: {"organization_id"=>1, "api_version"=>"v2", "content_export"=>{"organization_id"=>1, "format"=>"importable"}}
2024-05-02T15:17:36 [I|bac|c3dadce9] Task {label: , execution_plan_id: 0a355289-4876-448a-9ab0-76f56cc0fc08} state changed: pending 
2024-05-02T15:17:36 [I|bac|c3dadce9] Task {label: Actions::Pulp3::Orchestration::ContentViewVersion::ExportLibrary, id: 7f471020-0991-48a2-a55f-e87e1d4e11e2, execution_plan_id: 0a355289-4876-448a-9ab0-76f56cc0fc08} state changed: planning 
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on name Export-Library
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on label Export-Library
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on description 
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on organization_id 1
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on default false
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on composite false
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on next_version 1
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on force_puppet_environment false
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on auto_publish false
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on solve_dependencies false
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on import_only false
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on generated_for 1
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on repository_ids []
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on environment_ids []
2024-05-02T15:17:36 [I|aud|c3dadce9] Katello::ContentView (2) create event on filter_ids []
2024-05-02T15:17:36 [E|bac|c3dadce9] Validation failed: Label has already been taken, Name has already been taken (ActiveRecord::RecordInvalid)
 c3dadce9 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:80:in `raise_validation_error'
 c3dadce9 | /usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:53:in `save!'

~~

Expected results:

No such errors and the role should allow an user to export contents. 


Additional info:

The role "Content Exporter" does not have the create_content_views permission i.e. 

# hammer -u admin -p RedHat1! role filters --id 22
----|----------------------|--------|------------|-----------|------------------|-----------------------------------
ID  | RESOURCE TYPE        | SEARCH | UNLIMITED? | OVERRIDE? | ROLE             | PERMISSIONS                       
----|----------------------|--------|------------|-----------|------------------|-----------------------------------
242 | Katello::ContentView | none   | yes        | no        | Content Exporter | view_content_views                
243 | Organization         | none   | yes        | no        | Content Exporter | export_content, view_organizations
244 | Katello::Product     | none   | yes        | no        | Content Exporter | view_products                     
----|----------------------|--------|------------|-----------|------------------|-----------------------------------


So, i cloned that role and added that permission and then assigned that role to my sat-exporter user:

# hammer -u admin -p RedHat1! role filters --id 33
----|----------------------|--------|------------|-----------|------------------------|-----------------------------------
ID  | RESOURCE TYPE        | SEARCH | UNLIMITED? | OVERRIDE? | ROLE                   | PERMISSIONS                       
----|----------------------|--------|------------|-----------|------------------------|-----------------------------------
321 | Katello::ContentView | none   | yes        | no        | Content Exporter Fixed | view_content_views                
322 | Organization         | none   | yes        | no        | Content Exporter Fixed | export_content, view_organizations
323 | Katello::Product     | none   | yes        | no        | Content Exporter Fixed | view_products                     
324 | Katello::ContentView | none   | yes        | no        | Content Exporter Fixed | create_content_views              
----|----------------------|--------|------------|-----------|------------------------|-----------------------------------

# hammer -u admin -p RedHat1! user info --id 5 --fields login,roles
Login: sat_export
Roles: 
    Content Exporter Fixed


And now all commands are working as expected:

# hammer content-export complete library --format importable --organization-id 1 --destination-server disconnected_satellite
[..............................................................................................................................................................................................................................] [100%]

# hammer content-export complete library --format syncable --organization-id 1 
[..............................................................................................................................................................................................................................] [100%]
Generated /var/lib/pulp/exports/ACME/Export-Library-SYNCABLE/1.0/2024-05-02T15-29-00-05-30/metadata.json

# hammer content-export complete library --format syncable --organization-id 1  --destination-server disconnected_satellite
[..............................................................................................................................................................................................................................] [100%]
Generated /var/lib/pulp/exports/ACME/Export-Library-SYNCABLE-disconnected_satellite/1.0/disconnected_satellite/2024-05-02T15-29-18-05-30/metadata.json


# hammer content-export incremental library --format syncable --organization-id 1  --destination-server disconnected_satellite
[..............................................................................................................................................................................................................................] [100%]
Generated /var/lib/pulp/exports/ACME/Export-Library-SYNCABLE-disconnected_satellite/2.0/disconnected_satellite/2024-05-02T15-32-38-05-30/metadata.json



~~~~~~~

2024-05-02T15:26:47 [I|app|a60e418d] Started POST "/katello/api/content_exports/library" for 10.10.1.5 at 2024-05-02 15:26:47 +0530
2024-05-02T15:26:47 [I|app|a60e418d] Processing by Katello::Api::V2::ContentExportsController#library as */*
2024-05-02T15:26:47 [I|app|a60e418d]   Parameters: {"organization_id"=>1, "api_version"=>"v2", "content_export"=>{"organization_id"=>1, "format"=>"importable"}}
2024-05-02T15:26:47 [I|app|a60e418d] Authorized user sat_export(sat_export)
2024-05-02T15:26:47 [I|bac|a60e418d] Task {label: , execution_plan_id: f0bbb0ec-028c-4a4d-b75c-e403b9c33001} state changed: pending 
2024-05-02T15:26:47 [I|bac|a60e418d] Task {label: Actions::Pulp3::Orchestration::ContentViewVersion::ExportLibrary, id: ec4e8f07-ae4c-41cc-9d5b-40cb2eeeceb8, execution_plan_id: f0bbb0ec-028c-4a4d-b75c-e403b9c33001} state changed: planning 
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on name Export-Library
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on label Export-Library
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on description 
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on organization_id 1
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on default false
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on composite false
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on next_version 1
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on force_puppet_environment false
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on auto_publish false
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on solve_dependencies false
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on import_only false
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on generated_for 1
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on repository_ids []
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on environment_ids []
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) create event on filter_ids []
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) update event on repository_ids , 1, 2
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on content_view_id 7
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on major 1
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on definition_archive_id 
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on minor 0
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on content_counts 
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on applied_filters 
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on repository_ids []
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentViewVersion (2) create event on environment_ids []
2024-05-02T15:26:47 [I|aud|a60e418d] Katello::ContentView (7) update event on next_version 1, 2
..
..
~~~~~~~~~~


I even tested with Ansible Modules and they are working fine as expected without that error.

So maybe, something like this would be needed:

# git diff
diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb
index 95c2b50..7f27860 100644
--- a/lib/katello/plugin.rb
+++ b/lib/katello/plugin.rb
@@ -757,7 +757,7 @@ Foreman::Plugin.register :katello do
   ], 'Role granting permission to import content views in an organization'
 
   role 'Content Exporter', [
-    :export_content, :view_products, :view_content_views, :view_organizations
+    :export_content, :view_products, :view_content_views, :create_content_views, :view_organizations
   ], 'Role granting permission to export content views in an organization'
 
   def find_katello_assets(args = {})

Comment 4 Sayan Das 2024-05-09 10:58:55 UTC
Connecting the redmine and the PR

Bug #37430: Content Exporter role is missing the create_content_views permission - Katello - Foreman
https://projects.theforeman.org/issues/37430

Fixes #37430 - Added create_content_views permission in Content Expor… by sayan3296 · Pull Request #10991 · Katello/katello
https://github.com/Katello/katello/pull/10991

Comment 5 Eric Helms 2024-05-16 16:18:56 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/37430 has been resolved.

Comment 6 Eric Helms 2024-06-06 17:36:22 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.