Project

General

Profile

Actions

Bug #17463

closed

Importing classes for a new org fails when the environment already exist in a different org

Added by Tomáš Strachota over 7 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Puppet integration
Target version:
Fixed in Releases:
Found in Releases:

Description

Steps to reproduce:

  1. import classes in the default organization
  2. create a new organization B
  3. create a new user "john", assign him only to organization B
  4. run: hammer -u john proxy import-classes --id 1

The import currently fails with:

# hammer -u john proxy import-classes --id 1
Import of puppet classes failed:
  Validation failed: Organization ids Invalid organizations selection, you must select at least one of yours, Name has already been taken

Importing classes for a specific environment works fine (hammer -u john proxy import-classes --id 1 --environment production).

Expected results:
The api should automatically select user's orgs and import environments and classes for all of them. The api (and hammer) should also provide a parameter for selecting specific organization(s) for the import.

Additional info:
Relevant part of server log:

2016-11-23T12:03:31 5257aa7d [app] [I] Processing by Api::V2::SmartProxiesController#import_puppetclasses as JSON                                           
2016-11-23T12:03:31 5257aa7d [app] [I]   Parameters: {"dryrun"=>false, "apiv"=>"v2", "environment_id"=>"1", "id"=>"1", "smart_proxy"=>{}}
2016-11-23T12:03:31 5257aa7d [app] [I] Authorized user john(john)
2016-11-23T12:03:32 5257aa7d [app] [I] Completed 200 OK in 587ms (Views: 0.2ms | ActiveRecord: 32.6ms)
2016-11-23T12:03:39 923d3497 [app] [I] Started POST "/api/smart_proxies/1/import_puppetclasses" for fe80::5054:ff:fef5:1b57 at 2016-11-23 12:03:39 +0000    
2016-11-23T12:03:39 923d3497 [app] [I] Processing by Api::V2::SmartProxiesController#import_puppetclasses as JSON                                           
2016-11-23T12:03:39 923d3497 [app] [I]   Parameters: {"dryrun"=>false, "apiv"=>"v2", "id"=>"1", "smart_proxy"=>{}}
2016-11-23T12:03:39 923d3497 [app] [I] Authorized user john(john)
2016-11-23T12:03:41 923d3497 [app] [W] Action failed                                                                                                        
 | ActiveRecord::RecordInvalid: Validation failed: Organization ids Invalid organizations selection, you must select at least one of yours, Name has already been taken                                                                                                                                                 
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/validations.rb:79:in `raise_record_invalid'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/validations.rb:43:in `save!'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:291:in `block in save!'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in `transaction'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:291:in `save!'
 | /usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/persistence.rb:51:in `create!'
 | /root/foreman/foreman/app/services/puppet_class_importer.rb:269:in `find_or_create_env'
 | /root/foreman/foreman/app/services/puppet_class_importer.rb:192:in `add_classes_to_foreman'
 | /root/foreman/foreman/app/services/puppet_class_importer.rb:59:in `block in obsolete_and_new'
 | /root/foreman/foreman/app/services/puppet_class_importer.rb:57:in `each'
 | /root/foreman/foreman/app/services/puppet_class_importer.rb:57:in `obsolete_and_new'
 | /root/foreman/foreman/app/controllers/concerns/api/import_puppetclasses_common_controller.rb:42:in `import_puppetclasses'
 ...
2016-11-23T12:03:41 923d3497 [app] [I]   Rendered api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout (0.6ms)
2016-11-23T12:03:41 923d3497 [app] [I] Completed 500 Internal Server Error in 2183ms (Views: 2.3ms | ActiveRecord: 33.4ms)


Related issues 6 (0 open6 closed)

Related to Foreman - Bug #18995: Puppet class import removes existing environments when orgs/locations are disabledClosedDaniel Lobato Garcia03/23/2017Actions
Related to Foreman - Bug #18996: User#visible_environments limits to misspelt "view_environemnts" permissionsClosedDaniel Lobato Garcia03/23/2017Actions
Related to Foreman - Bug #20340: Updating puppet environment which is not associated with organization creates internal server errorResolved07/19/2017Actions
Related to Foreman - Bug #20418: Set proper taxonomy scope when importing puppet classesClosedOndřej Pražák07/26/2017Actions
Related to Katello - Bug #19338: CV publishing with puppet module does not add puppet classClosedBrad Buckingham04/20/2017Actions
Related to Foreman - Bug #21503: Importing puppet classes fails when switching to different orgClosedOndřej Pražák10/30/2017Actions
Actions #1

Updated by Ondřej Pražák about 7 years ago

  • Assignee set to Ondřej Pražák
Actions #2

Updated by The Foreman Bot about 7 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4242 added
Actions #3

Updated by Anonymous about 7 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #4

Updated by The Foreman Bot about 7 years ago

  • Pull request https://github.com/theforeman/foreman/pull/4371 added
Actions #5

Updated by Dominic Cleal about 7 years ago

  • Related to Bug #18995: Puppet class import removes existing environments when orgs/locations are disabled added
Actions #6

Updated by Dominic Cleal about 7 years ago

  • Related to Bug #18996: User#visible_environments limits to misspelt "view_environemnts" permissions added
Actions #7

Updated by Ohad Levy about 7 years ago

  • translation missing: en.field_release set to 209
Actions #8

Updated by Marek Hulán almost 7 years ago

  • Related to Bug #20340: Updating puppet environment which is not associated with organization creates internal server error added
Actions #9

Updated by Ondřej Pražák almost 7 years ago

  • Related to Bug #20418: Set proper taxonomy scope when importing puppet classes added
Actions #10

Updated by Ondřej Pražák almost 7 years ago

  • Related to Bug #19338: CV publishing with puppet module does not add puppet class added
Actions #11

Updated by Ondřej Pražák over 6 years ago

  • Related to Bug #21503: Importing puppet classes fails when switching to different org added
Actions

Also available in: Atom PDF