Commit 33e8d1b4 authored by Mitchell Nielsen's avatar Mitchell Nielsen Committed by charlie ablett

Remove upcoming database deprecation warning

Removes upcoming database deprecation warning feature from the admin UI.
The only related notice that will appear is if the current database
version does not meet the required minimum.

Upcoming database deprecations will continue to be shared in normal
channels. This feature does not initially appear to offer much benefit
to end users, and can even cause some confusion.
parent 0245dd44
---
title: Display upcoming database deprecation warning only if current database version minimum is not met
merge_request: 38225
author:
type: removed
......@@ -6,48 +6,21 @@ module Gitlab
extend self
def check
notices = []
unless Gitlab::Database.postgresql_minimum_supported_version?
string_args = {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url_open: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">'.html_safe,
pg_requirements_url_close: '</a>'.html_safe
return [] if Gitlab::Database.postgresql_minimum_supported_version?
[
{
type: 'warning',
message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url} for details.') % {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
}
}
notices <<
{
type: 'warning',
message: html_escape(_('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url_open}database requirements%{pg_requirements_url_close} for details.')) % string_args
}
end
if Gitlab::Database.postgresql_upcoming_deprecation? && Gitlab::Database.within_deprecation_notice_window?
upcoming_deprecation = Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS
string_args = {
pg_version_upcoming: upcoming_deprecation[:pg_version_minimum],
gl_version_upcoming: upcoming_deprecation[:gl_version],
gl_version_upcoming_date: upcoming_deprecation[:gl_version_date],
pg_version_upcoming_url_open: "<a href=\"#{upcoming_deprecation[:url]}\">".html_safe,
pg_version_upcoming_url_close: '</a>'.html_safe
}
notices <<
{
type: 'warning',
message: html_escape(_('Note that PostgreSQL %{pg_version_upcoming} will become the minimum required ' \
'version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please ' \
'consider upgrading your environment to a supported PostgreSQL version soon, ' \
'see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details.')) % string_args
}
end
notices
]
end
end
end
......
......@@ -6,20 +6,6 @@ module Gitlab
# https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements
MINIMUM_POSTGRES_VERSION = 11
# Upcoming PostgreSQL version requirements
# Allows a soft warning about an upcoming minimum version requirement
# so administrators can prepare to upgrade
UPCOMING_POSTGRES_VERSION_DETAILS = {
gl_version: '13.6.0',
gl_version_date: 'November 22, 2020',
pg_version_minimum: 12,
url: 'https://gitlab.com/groups/gitlab-org/-/epics/2374'
}.freeze
# Specifies the maximum number of days in advance to display a notice
# regarding an upcoming PostgreSQL version deprecation.
DEPRECATION_WINDOW_DAYS = 90
# https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
MAX_INT_VALUE = 2147483647
MIN_INT_VALUE = -2147483648
......@@ -114,22 +100,6 @@ module Gitlab
version.to_f >= MINIMUM_POSTGRES_VERSION
end
def self.postgresql_upcoming_deprecation?
version.to_f < UPCOMING_POSTGRES_VERSION_DETAILS[:pg_version_minimum]
end
def self.days_until_deprecation
(
Date.parse(UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) -
Date.today
).to_i
end
private_class_method :days_until_deprecation
def self.within_deprecation_notice_window?
days_until_deprecation <= DEPRECATION_WINDOW_DAYS
end
def self.check_postgres_version_and_print_warning
return if Gitlab::Database.postgresql_minimum_supported_version?
return if Gitlab::Runtime.rails_runner?
......
......@@ -16622,9 +16622,6 @@ msgstr ""
msgid "Note parameters are invalid: %{errors}"
msgstr ""
msgid "Note that PostgreSQL %{pg_version_upcoming} will become the minimum required version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please consider upgrading your environment to a supported PostgreSQL version soon, see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details."
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 ""
......@@ -27930,7 +27927,7 @@ msgstr ""
msgid "You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico."
msgstr ""
msgid "You are using PostgreSQL %{pg_version_current}, but PostgreSQL %{pg_version_minimum} is required for this version of GitLab. Please upgrade your environment to a supported PostgreSQL version, see %{pg_requirements_url_open}database requirements%{pg_requirements_url_close} for details."
msgid "You are using PostgreSQL %{pg_version_current}, but PostgreSQL %{pg_version_minimum} is required for this version of GitLab. Please upgrade your environment to a supported PostgreSQL version, see %{pg_requirements_url} for details."
msgstr ""
msgid "You can %{linkStart}view the blob%{linkEnd} instead."
......
......@@ -6,84 +6,35 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
describe '#check' do
subject { described_class.check }
let_it_be(:deprecation_warning) { "Please upgrade" }
let_it_be(:upcoming_deprecation_warning) { "Please consider upgrading" }
context 'when database meets minimum version and there is no upcoming deprecation' do
context 'when database meets minimum supported version' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
end
it { is_expected.to be_empty }
end
context 'when database does not meet minimum version and there is no upcoming deprecation' do
context 'when database does not meet minimum supported version' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
end
it 'only returns notice about deprecated database version' do
is_expected.to include(a_hash_including(message: include(deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning)))
end
end
context 'when database meets minimum version and there is an upcoming deprecation' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true)
let(:notice_deprecated_database) do
{
type: 'warning',
message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url} for details.') % {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
}
}
end
context 'inside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true)
end
it 'only returns notice about an upcoming deprecation' do
is_expected.to include(a_hash_including(message: include(upcoming_deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(deprecation_warning)))
end
end
context 'outside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false)
end
it { is_expected.to be_empty }
end
end
context 'when database does not meet minimum version and there is an upcoming deprecation' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true)
end
context 'inside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true)
end
it 'returns notice about deprecated database version and an upcoming deprecation' do
is_expected.to include(
a_hash_including(message: include(deprecation_warning)),
a_hash_including(message: include(upcoming_deprecation_warning))
)
end
end
context 'outside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false)
end
it 'only returns notice about deprecated database version' do
is_expected.to include(a_hash_including(message: include(deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning)))
end
it 'reports deprecated database notice' do
is_expected.to contain_exactly(notice_deprecated_database)
end
end
end
......
......@@ -109,46 +109,6 @@ RSpec.describe Gitlab::Database do
end
end
describe '.postgresql_upcoming_deprecation?' do
it 'returns true when database version is lower than the upcoming minimum' do
allow(described_class).to receive(:version).and_return('11')
expect(described_class.postgresql_upcoming_deprecation?).to eq(true)
end
it 'returns false when database version equals the upcoming minimum' do
allow(described_class).to receive(:version).and_return('12')
expect(described_class.postgresql_upcoming_deprecation?).to eq(false)
end
it 'returns false when database version is greater the upcoming minimum' do
allow(described_class).to receive(:version).and_return('13')
expect(described_class.postgresql_upcoming_deprecation?).to eq(false)
end
end
describe '.within_deprecation_notice_window?' do
using RSpec::Parameterized::TableSyntax
where(:case_name, :days, :result) do
'outside window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS + 1 | false
'equal to window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS | true
'within window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS - 1 | true
end
with_them do
it "returns #{params[:result]} when #{params[:case_name]}" do
allow(Date)
.to receive(:today)
.and_return Date.parse(Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) - days
expect(described_class.within_deprecation_notice_window?).to eq(result)
end
end
end
describe '.check_postgres_version_and_print_warning' do
subject { described_class.check_postgres_version_and_print_warning }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment