Project

General

Profile

Refactor #24619

With Rails 5.2 db:create fails when plugins present

Added by Ivan Necas 4 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
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

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

Associated revisions

Revision 0f5497a6 (diff)
Added by Ivan Necas 4 months ago

Fixes #24619 - handle Rails env in db:create

This is a change needed for migration to Rails 5.2

History

#1 Updated by Ivan Necas 4 months ago

#2 Updated by Ivan Necas 4 months ago

  • Tracker changed from Bug to Refactor

#3 Updated by Ivan Necas 4 months ago

#4 Updated by The Foreman Bot 4 months ago

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

#5 Updated by Michael Moll 4 months ago

  • Fixed in Releases 1.20.0 added

#6 Updated by Ivan Necas 4 months ago

  • Status changed from Ready For Testing to Closed

#7 Updated by Tomer Brisker 2 months ago

  • Category set to Rails

Also available in: Atom PDF