diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index cd95105a893c283574b8e15a7f15770fdf9f702f..b7b535e70df611aba378bff5ff7e8bd0af46959b 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -13,6 +13,7 @@ def index @users = User.order_id_desc.limit(10) @groups = Group.order_id_desc.with_route.limit(10) @notices = Gitlab::ConfigChecker::PumaRuggedChecker.check + @notices += Gitlab::ConfigChecker::ExternalDatabaseChecker.check end # rubocop: enable CodeReuse/ActiveRecord diff --git a/changelogs/unreleased/display-db-deprecation-notice.yml b/changelogs/unreleased/display-db-deprecation-notice.yml new file mode 100644 index 0000000000000000000000000000000000000000..b402beba0d2ebe1d5536911e3a5f8b70b5707340 --- /dev/null +++ b/changelogs/unreleased/display-db-deprecation-notice.yml @@ -0,0 +1,5 @@ +--- +title: Implement external database checker in dashboard controller +merge_request: 30389 +author: +type: deprecated diff --git a/doc/install/requirements.md b/doc/install/requirements.md index e3981b6b92bd177acae45d4213eab894f93ca5a3..a16b69244dd2eb32d24f431097d95cf38ebdb1b3 100644 --- a/doc/install/requirements.md +++ b/doc/install/requirements.md @@ -139,9 +139,12 @@ MySQL/MariaDB are advised to [migrate to PostgreSQL](../update/mysql_to_postgres ### PostgreSQL Requirements -As of GitLab 10.0, PostgreSQL 9.6 or newer is required, and earlier versions are -not supported. We highly recommend users to use PostgreSQL 9.6 as this -is the PostgreSQL version used for development and testing. +We highly recommend users to use the minimum PostgreSQL versions specified below as these are the versions used for development and testing. + +GitLab version | Minimum PostgreSQL version +-|- +10.0 | 9.6 +12.10 | 11 Users using PostgreSQL must ensure the `pg_trgm` extension is loaded into every GitLab database. This extension can be enabled (using a PostgreSQL super user) diff --git a/lib/gitlab/config_checker/external_database_checker.rb b/lib/gitlab/config_checker/external_database_checker.rb new file mode 100644 index 0000000000000000000000000000000000000000..795082a10a01329c3538a7e1305083734506622b --- /dev/null +++ b/lib/gitlab/config_checker/external_database_checker.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Gitlab + module ConfigChecker + module ExternalDatabaseChecker + extend self + + # DB is considered deprecated if it is below version 11 + def db_version_deprecated? + Gitlab::Database.version.to_f < 11 + end + + def check + return [] unless db_version_deprecated? + + [ + { + type: 'warning', + message: _('Note that PostgreSQL 11 will become the minimum required PostgreSQL version in GitLab 13.0 (May 2020). '\ + 'PostgreSQL 9.6 and PostgreSQL 10 will no longer be supported in GitLab 13.0. '\ + 'Please consider upgrading your PostgreSQL version (%{db_version}) soon.') % { db_version: Gitlab::Database.version.to_s } + } + ] + end + end + end +end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 48175627cdd1f2a52227a634491a4a50817c1831..06b7b8f4bc16ee98ec0986604487cf52d37e32d8 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,6 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-04-24 17:33-0400\n" +"PO-Revision-Date: 2020-04-24 17:33-0400\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: \n" @@ -14077,6 +14079,9 @@ msgstr "" msgid "Note parameters are invalid: %{errors}" msgstr "" +msgid "Note that PostgreSQL 11 will become the minimum required PostgreSQL version in GitLab 13.0 (May 2020). PostgreSQL 9.6 and PostgreSQL 10 will no longer be supported in GitLab 13.0. Please consider upgrading your PostgreSQL version (%{db_version}) soon." +msgstr "" + msgid "Note that this invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}." msgstr "" diff --git a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..d86d132c237667dee8e50ec23a77289ba223fe09 --- /dev/null +++ b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::ConfigChecker::ExternalDatabaseChecker do + describe '#check' do + subject { described_class.check } + + context 'database version is not deprecated' do + before do + allow(described_class).to receive(:db_version_deprecated?).and_return(false) + end + + it { is_expected.to be_empty } + end + + context 'database version is deprecated' do + before do + allow(described_class).to receive(:db_version_deprecated?).and_return(true) + end + + let(:notice_deprecated_database) do + { + type: 'warning', + message: _('Note that PostgreSQL 11 will become the minimum required PostgreSQL version in GitLab 13.0 (May 2020). '\ + 'PostgreSQL 9.6 and PostgreSQL 10 will no longer be supported in GitLab 13.0. '\ + 'Please consider upgrading your PostgreSQL version (%{db_version}) soon.') % { db_version: Gitlab::Database.version.to_s } + } + end + + it 'reports deprecated database notices' do + is_expected.to contain_exactly(notice_deprecated_database) + end + end + end + + describe '#db_version_deprecated' do + subject { described_class.db_version_deprecated? } + + context 'database version is not deprecated' do + before do + allow(Gitlab::Database).to receive(:version).and_return(11) + end + + it { is_expected.to be false } + end + + context 'database version is deprecated' do + before do + allow(Gitlab::Database).to receive(:version).and_return(10) + end + + it { is_expected.to be true } + end + end +end