Project

General

Profile

Bug #37430

Updated by Sayan Das 6 months ago

It's common to have a non-admin user with specific role trying to perform a specific task through API and in case of exporting some content ( library\repo\cv version ), When using "Content Exporter" role with an user, then export attempt via that user will always end up failing with errors like this i.e.  

 <pre> 
 Could not export the repository: 
   Validation failed: Label has already been taken, Name has already been taken 
 </pre> 


 Trace: 

 <pre> 
 2024-05-09T16:00:45 [I|aud|4e8d0c49] Katello::ContentView (10) create event on generated_for 2 
 2024-05-09T16:00:45 [I|aud|4e8d0c49] Katello::ContentView (10) create event on repository_ids [] 
 2024-05-09T16:00:45 [I|aud|4e8d0c49] Katello::ContentView (10) create event on environment_ids [] 
 2024-05-09T16:00:45 [I|aud|4e8d0c49] Katello::ContentView (10) create event on filter_ids [] 
 2024-05-09T16:00:45 [E|bac|4e8d0c49] Validation failed: Label has already been taken, Name has already been taken (ActiveRecord::RecordInvalid) 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/validations.rb:80:in `raise_validation_error' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/validations.rb:53:in `save!' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:302:in `block in save!' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:350:in `with_transaction_returning_status' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:302:in `save!' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/suppressor.rb:48:in `save!' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/persistence.rb:639:in `block in update!' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:350:in `with_transaction_returning_status' 
  4e8d0c49 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/persistence.rb:637:in `update!' 
  4e8d0c49 | /usr/share/gems/gems/katello-4.11.0.9/app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb:17:in `plan' 
 </pre> 


 This is because, When it was time to create the Content View, The user did not have enough permission to work with.  

 <pre> 
 # hammer role filters --name "Content Exporter" 
 ----|----------------------|--------|------------|-----------|------------------|----------------------------------- 
 ID    | RESOURCE TYPE          | SEARCH | UNLIMITED? | OVERRIDE? | ROLE               | PERMISSIONS                        
 ----|----------------------|--------|------------|-----------|------------------|----------------------------------- 
 249 | Katello::ContentView | none     | yes          | no          | Content Exporter | view_content_views                 
 250 | Organization           | none     | yes          | no          | Content Exporter | export_content, view_organizations 
 251 | Katello::Product       | none     | yes          | no          | Content Exporter | view_products                      
 ----|----------------------|--------|------------|-----------|------------------|----------------------------------- 

 </pre> 
 We simply need to add create_content_views permission in that specific role.

Back