Skip to content
Snippets Groups Projects
Commit 6fee79aa6b21 authored by Clemens Beck's avatar Clemens Beck
Browse files

Require upgrade stop at 16.3

GitLab 16.3 is a required upgrade stop for 16.4.

See: https://docs.gitlab.com/ee/update/#upgrade-paths

Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8103

Changelog: changed
parent 12e079dbf316
3 merge requests!114heptapod#1394: making 1.0 the oldstable,!110heptapod#1352: merged heptapod branch into heptapod-stable,!106Merged upstream 16.4 branching point into heptapod branch
......@@ -40,7 +40,7 @@
upgrade_check() {
# Minimum version from which jumps are permitted to current version.
# Follows https://docs.gitlab.com/ee/update/index.html#upgrade-paths
MIN_VERSION=15.11
MIN_VERSION=16.3
if [ -n "${OLD_VERSION_STRING}" ] ; then
# Checking
......@@ -44,10 +44,13 @@
if [ -n "${OLD_VERSION_STRING}" ] ; then
# Checking
# (i) if it is a major version jump
# (ii) if existing version is less than required minimum version
if test ${OLD_MAJOR_VERSION} -lt ${NEW_MAJOR_VERSION}; then
if ! greater_version $OLD_MINOR_VERSION $MIN_VERSION; then
notify "It seems you are upgrading from major version ${OLD_MAJOR_VERSION} to major version ${NEW_MAJOR_VERSION}."
notify "It is required to upgrade to the latest ${MIN_VERSION}.x version first before proceeding."
# If existing version is less than required minimum version, do not permit the upgrade.
if ! greater_version $OLD_MINOR_VERSION $MIN_VERSION; then
notify "It seems you are upgrading from ${OLD_MINOR_VERSION} to ${NEW_MINOR_VERSION}."
notify "It is required to upgrade to the latest ${MIN_VERSION}.x version first before proceeding."
# If the upgrade is a major version jump, print a major upgrade notification.
if test ${OLD_MAJOR_VERSION} -lt ${NEW_MAJOR_VERSION}; then
notify "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/#upgrading-to-a-new-major-version"
else
notify "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrade-paths"
......@@ -53,3 +56,2 @@
notify "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrade-paths"
exit 1
fi
......@@ -55,4 +57,5 @@
fi
exit 1
fi
fi
}
......
......@@ -119,7 +119,7 @@
then
GITLAB_UPGRADE='true'
new_version=$(awk '/^gitlab-(ce|ee|jh)/ {print $NF}' /opt/gitlab/version-manifest.txt)
MIN_VERSION="15.11" gitlab-ctl upgrade-check "${old_version}" "${new_version}"
gitlab-ctl upgrade-check "${old_version}" "${new_version}"
fi
# Copy gitlab.rb for the first time
......
module GitlabCtl
class UpgradeCheck
MIN_VERSION = ENV['MIN_VERSION'] || '15.11'.freeze
class <<self
......@@ -5,5 +3,5 @@
class <<self
def valid?(ov, nv)
def valid?(ov)
# If old_version is nil, this is a fresh install
return true if ov.nil?
......@@ -7,7 +5,9 @@
# If old_version is nil, this is a fresh install
return true if ov.nil?
old_version_major = ov.split('.').first
old_version_minor = ov.split('.')[0..1].join('.')
new_version_major = nv.split('.').first
old_version_major = ov.split('.')[0]
old_version_minor = ov.split('.')[1]
min_version = min_version()
min_version_major = min_version.split('.')[0]
min_version_minor = min_version.split('.')[1]
......@@ -13,5 +13,5 @@
if old_version_major < new_version_major
return false if old_version_minor != MIN_VERSION
end
minimum_version_detected = old_version_major == min_version_major && old_version_minor >= min_version_minor
minimum_version_detected || old_version_major > min_version_major
end
......@@ -17,5 +17,6 @@
true
def min_version
ENV['MIN_VERSION'] || '16.3'.freeze
end
end
end
......
......@@ -3,10 +3,14 @@
add_command('upgrade-check', 'Check if the upgrade is acceptable', 2) do
old_version = ARGV[3]
new_version = ARGV[4]
unless GitlabCtl::UpgradeCheck.valid?(old_version, new_version)
warn "It seems you are upgrading from major version #{old_version.split('.').first} to major version #{new_version.split('.').first}."
warn "It is required to upgrade to the latest #{GitlabCtl::UpgradeCheck::MIN_VERSION}.x version first before proceeding."
warn "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrading-to-a-new-major-version"
unless GitlabCtl::UpgradeCheck.valid?(old_version)
old_major = old_version.split('.').first.to_i
new_major = new_version.split('.').first.to_i
is_major_upgrade = new_major > old_major
warn "It seems you are upgrading from #{old_version} to #{new_version}."
warn "It is required to upgrade to the latest #{GitlabCtl::UpgradeCheck.min_version}.x version first before proceeding."
warn "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrading-to-a-new-major-version" if is_major_upgrade
warn "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/#upgrade-paths" unless is_major_upgrade
Kernel.exit 1
end
end
......@@ -5,11 +5,7 @@
require 'gitlab_ctl/upgrade_check'
RSpec.describe GitlabCtl::UpgradeCheck do
let(:latest) { '13.1.3' }
let(:previous_major) { '12.5.10' }
let(:previous_major_latest) { '12.10.13' }
let(:current_major) { '13.0.8' }
let(:old) { '11.5.11' }
using RSpec::Parameterized::TableSyntax
context 'not an upgrade' do
it 'returns true' do
......@@ -13,7 +9,7 @@
context 'not an upgrade' do
it 'returns true' do
expect(described_class.valid?(nil, latest)).to be true
expect(described_class.valid?(nil)).to be true
end
end
......@@ -17,9 +13,21 @@
end
end
context 'valid upgrade paths' do
it 'returns true for an upgrade from the current major version' do
expect(described_class.valid?(current_major, latest)).to be true
context 'when following valid upgrade paths' do
where(:old_version, :min_version) do
'15.11.0' | '15.11'
'15.11.0' | '15.11'
'15.11.5' | '15.11'
'16.3.0' | '16.3'
'16.3.3' | '16.3'
'17.1.0' | '16.3'
end
with_them do
it "returns true" do
stub_env_var('MIN_VERSION', min_version)
expect(described_class.valid?(old_version)).to be true
end
end
end
......@@ -23,8 +31,10 @@
end
end
context 'invalid upgrade paths' do
it 'returns false for an upgrade from 11.5 to the latest' do
expect(described_class.valid?(old, latest)).to be false
context 'when following invalid upgrade paths' do
where(:old_version, :min_version) do
'15.11.0' | '16.3'
'16.2.0' | '16.3'
'16.2.4' | '16.3'
end
......@@ -29,11 +39,10 @@
end
it 'returns false for an upgrade from 12.5 to the latest' do
expect(described_class.valid?(previous_major, latest)).to be false
end
it 'returns false upgrading from previous_major_latest to the latest' do
expect(described_class.valid?(previous_major_latest, latest)).to be false
with_them do
it "returns false" do
stub_env_var('MIN_VERSION', min_version)
expect(described_class.valid?(old_version)).to be false
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment