Actions
Bug #25312
closedadd_permissions_to_default_roles fails during db:create
Difficulty:
Triaged:
No
Bugzilla link:
Description
(from http://ci.theforeman.org/blue/organizations/jenkins/katello-pr-test/detail/katello-pr-test/3578/pipeline/ that tests https://github.com/Katello/katello/pull/7532)
when calling add_permissions_to_default_roles
in Foreman::Plugin.register
, the code is also executed during rake db:create
, but at that point the tables are not created yet and db:create fails:
ActiveRecord::NoDatabaseError: FATAL: database "katello-pr-test-3578-development" does not exist /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:688:in `rescue in connect' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:683:in `connect' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:215:in `initialize' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `new' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `postgresql_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:90:in `connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:466:in `load_schema!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/attributes.rb:234:in `load_schema!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/attribute_decorators.rb:51:in `load_schema!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:459:in `block in load_schema' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:456:in `load_schema' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:336:in `columns_hash' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `block in find_by' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `each' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `all?' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `find_by' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin/rbac_support.rb:34:in `block in add_permissions_to_default_roles' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin/rbac_support.rb:32:in `each' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin/rbac_support.rb:32:in `add_permissions_to_default_roles' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:310:in `block (2 levels) in add_permissions_to_default_roles' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/audited-4.8.0/lib/audited/auditor.rb:353:in `without_auditing' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:309:in `block in add_permissions_to_default_roles' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/audited-4.8.0/lib/audited/auditor.rb:353:in `without_auditing' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:308:in `add_permissions_to_default_roles' /var/lib/workspace/workspace/katello-pr-test/lib/katello/plugin.rb:318:in `block in <main>' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:74:in `instance_eval' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:74:in `register' /var/lib/workspace/workspace/katello-pr-test/lib/katello/plugin.rb:5:in `<main>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require' /var/lib/workspace/workspace/katello-pr-test/lib/katello/engine.rb:59:in `block in <class:Engine>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing' /var/lib/workspace/workspace/katello-pr-test/foreman/config/environment.rb:5:in `<main>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/application.rb:337:in `require_environment!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/application.rb:520:in `block in run_tasks_blocks' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/rake-12.3.1/exe/rake:27:in `<top (required)>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/bin/ruby_executable_hooks:15:in `eval' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/bin/ruby_executable_hooks:15:in `<main>' Caused by: PG::ConnectionBad: FATAL: database "katello-pr-test-3578-development" does not exist /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/pg-1.1.3/lib/pg.rb:56:in `initialize' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/pg-1.1.3/lib/pg.rb:56:in `new' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/pg-1.1.3/lib/pg.rb:56:in `connect' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:684:in `connect' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:215:in `initialize' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `new' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `postgresql_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:90:in `connection' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:466:in `load_schema!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/attributes.rb:234:in `load_schema!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/attribute_decorators.rb:51:in `load_schema!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:459:in `block in load_schema' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:456:in `load_schema' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:336:in `columns_hash' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `block in find_by' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `each' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `all?' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activerecord-5.2.1/lib/active_record/core.rb:196:in `find_by' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin/rbac_support.rb:34:in `block in add_permissions_to_default_roles' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin/rbac_support.rb:32:in `each' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin/rbac_support.rb:32:in `add_permissions_to_default_roles' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:310:in `block (2 levels) in add_permissions_to_default_roles' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/audited-4.8.0/lib/audited/auditor.rb:353:in `without_auditing' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:309:in `block in add_permissions_to_default_roles' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/audited-4.8.0/lib/audited/auditor.rb:353:in `without_auditing' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:308:in `add_permissions_to_default_roles' /var/lib/workspace/workspace/katello-pr-test/lib/katello/plugin.rb:318:in `block in <main>' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:74:in `instance_eval' /var/lib/workspace/workspace/katello-pr-test/foreman/app/registries/foreman/plugin.rb:74:in `register' /var/lib/workspace/workspace/katello-pr-test/lib/katello/plugin.rb:5:in `<main>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require' /var/lib/workspace/workspace/katello-pr-test/lib/katello/engine.rb:59:in `block in <class:Engine>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing' /var/lib/workspace/workspace/katello-pr-test/foreman/config/environment.rb:5:in `<main>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/application.rb:337:in `require_environment!' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/railties-5.2.1/lib/rails/application.rb:520:in `block in run_tasks_blocks' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/gems/rake-12.3.1/exe/rake:27:in `<top (required)>' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/bin/ruby_executable_hooks:15:in `eval' /usr/local/rvm/gems/ruby-2.5.1@katello-pr-test-3578/bin/ruby_executable_hooks:15:in `<main>' Tasks: TOP => db:create => db:load_config => environment (See full trace by running task with --trace) script returned exit code 1
Actions