Project

General

Profile

Actions

Refactor #24619

closed

With Rails 5.2 db:create fails when plugins present

Added by Ivan Necas almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

It seems that in Rails 5.2, they started to initialize rails environment even in db:create rake tasks, causing issues in couple of places.

Steps to reproduce

1. configure foreman to use non-existing database
2. add a plugin
3. run `rake db:create`

Fails with:

07:06:00 ActiveRecord::NoDatabaseError: FATAL:  database "test_develop_pr_katello-0-dev" does not exist
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:688:in `rescue in connect'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:683:in `connect'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:215:in `initialize'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `new'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `postgresql_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:90:in `connection'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/schema_migration.rb:22:in `table_exists?'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/schema_migration.rb:26:in `create_table'
07:06:00 /usr/local/rvm/gems/ruby-2.4.3@test_develop_pr_katello-0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1187:in `initialize'
07:06:00 /var/lib/workspace/workspace/test_develop_pr_katello/database/postgresql/ruby/2.4/slave/fast/app/registries/foreman/plugin.rb:325:in `new'
07:06:00 /var/lib/workspace/workspace/test_develop_pr_katello/database/postgresql/ruby/2.4/slave/fast/app/registries/foreman/plugin.rb:325:in `pending_migrations'
07:06:00 /var/lib/workspace/workspace/test_develop_pr_katello/database/postgresql/ruby/2.4/slave/fast/app/registries/foreman/plugin.rb:269:in `permission'


Related issues 2 (0 open2 closed)

Related to Foreman - Refactor #24539: don't initialize dynflow in db:createClosedActions
Blocks Foreman - Tracker #21834: Rails 5.2 upgrade tasksClosed

Actions
Actions #1

Updated by Ivan Necas almost 6 years ago

Actions #2

Updated by Ivan Necas almost 6 years ago

  • Tracker changed from Bug to Refactor
Actions #3

Updated by Ivan Necas almost 6 years ago

Actions #4

Updated by The Foreman Bot almost 6 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5947 added
Actions #5

Updated by Anonymous almost 6 years ago

  • Fixed in Releases 1.20.0 added
Actions #6

Updated by Ivan Necas almost 6 years ago

  • Status changed from Ready For Testing to Closed
Actions #7

Updated by Tomer Brisker over 5 years ago

  • Category set to Rails
Actions

Also available in: Atom PDF