Project

General

Profile

Bug #20385

rake db:seed fails for plugins

Added by Marek Hulán over 1 year ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugins-Engines
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

The role fails to create on first_on_create because of missing create permission. The role plugins DSL is not running under admin which is the reason it fails. Only to be found with 1.16 (develop branch)

the trace

rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/validations.rb:79:in `raise_record_invalid'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/validations.rb:43:in `save!'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/transactions.rb:291:in `block in save!'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/transactions.rb:220:in `transaction'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/transactions.rb:291:in `save!'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/foreman/app/models/role.rb:169:in `add_permissions!'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/foreman/app/registries/foreman/plugin.rb:249:in `block in role'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activerecord-4.2.9/lib/active_record/transactions.rb:220:in `transaction'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/foreman/app/registries/foreman/plugin.rb:247:in `role'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/plugin/lib/foreman_openscap/engine.rb:115:in `block (2 levels) in <class:Engine>'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/foreman/app/registries/foreman/plugin.rb:66:in `instance_eval'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/foreman/app/registries/foreman/plugin.rb:66:in `register'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/plugin/lib/foreman_openscap/engine.rb:44:in `block in <class:Engine>'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/initializable.rb:30:in `run'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/application.rb:352:in `initialize!'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/railtie.rb:194:in `public_send'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/railtie.rb:194:in `method_missing'
/var/lib/workspace/workspace/test_plugin_pull_request/database/postgresql/label/fast/ruby/2.3/foreman/config/environment.rb:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/application.rb:328:in `require_environment!'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/railties-4.2.9/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.1@test_plugin_pull_request-2/bin/ruby_executable_hooks:15:in `<main>'


Related issues

Related to Foreman - Bug #16884: Create permissions do not check filter limitsClosed2016-10-12

Associated revisions

Revision 7eb33b59 (diff)
Added by Marek Hulán over 1 year ago

Fixes #20385 - fix the role plugin DSL

After create/update permission started to be enforced in Foreman 1.16,
the Role.where(:name => name).first_or_create can fail silently. The
newly built role is considered a new record which later when we add
permissions and save! it fails. The validation that prevents the
save is uniqueness on name.

History

#1 Updated by Marek Hulán over 1 year ago

  • Related to Bug #16884: Create permissions do not check filter limits added

#2 Updated by The Foreman Bot over 1 year ago

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

#3 Updated by Marek Hulán over 1 year ago

  • Description updated (diff)

#4 Updated by Ivan Necas over 1 year ago

  • Status changed from Ready For Testing to Closed
  • Legacy Backlogs Release (now unused) set to 240

Also available in: Atom PDF