Ensure Rake DB create doesn't fail when LDAP is enabled
What does this MR do?
Related to #225329 (closed)
In EE, when LDAP is enabled GitLab will try to determine whether multiple LDAP servers are supported on initialization. When Rake is trying to create a database for the first time, this attempt to look at a licensed feature caused a failure. Now this license lookup will fail silently.
The error prior to this change:
ActiveRecord::NoDatabaseError: FATAL: database "gitlabhq_development" does not exist
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:50:in `rescue in postgresql_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:33:in `postgresql_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_handling.rb:221:in `retrieve_connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/connection_handling.rb:189:in `connection'
/Users/shutin/.rvm/gems/ruby-2.6.6@gitlab-ee/gems/activerecord-6.0.3.1/lib/active_record/model_schema.rb:340:in `table_exists?'
/Users/shutin/www/gitlab/gitlab-rails/ee/app/models/license.rb:266:in `load_license'
/Users/shutin/www/gitlab/gitlab-rails/ee/app/models/license.rb:255:in `current'
/Users/shutin/www/gitlab/gitlab-rails/ee/app/models/license.rb:259:in `feature_available?'
/Users/shutin/www/gitlab/gitlab-rails/ee/lib/ee/gitlab/auth/ldap/config.rb:19:in `_available_servers'
/Users/shutin/www/gitlab/gitlab-rails/lib/gitlab/auth/ldap/config.rb:37:in `available_servers'
/Users/shutin/www/gitlab/gitlab-rails/config/initializers/omniauth.rb:3:in `<module:Strategies>'
/Users/shutin/www/gitlab/gitlab-rails/config/initializers/omniauth.rb:2:in `<main>'
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Drew Blessing