Skip to content

Commit 4574338

Browse files
Robert MarshallClemens Beck
andcommitted
Merge branch 'upgrade-stop-16-3' into 'master'
Require upgrade stop at 16.3 Closes #8103 See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7110 Merged-by: Robert Marshall <[email protected]> Approved-by: Dustin Collins <[email protected]> Approved-by: Robert Marshall <[email protected]> Reviewed-by: Robert Marshall <[email protected]> Co-authored-by: Clemens Beck <[email protected]>
2 parents f267ae9 + 07da7dd commit 4574338

File tree

5 files changed

+57
-40
lines changed

5 files changed

+57
-40
lines changed

config/templates/package-scripts/preinst.erb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,22 @@ fi
4040
upgrade_check() {
4141
# Minimum version from which jumps are permitted to current version.
4242
# Follows https://docs.gitlab.com/ee/update/index.html#upgrade-paths
43-
MIN_VERSION=15.11
43+
MIN_VERSION=16.3
4444

4545
if [ -n "${OLD_VERSION_STRING}" ] ; then
4646
# Checking
47-
# (i) if it is a major version jump
48-
# (ii) if existing version is less than required minimum version
49-
if test ${OLD_MAJOR_VERSION} -lt ${NEW_MAJOR_VERSION}; then
50-
if ! greater_version $OLD_MINOR_VERSION $MIN_VERSION; then
51-
notify "It seems you are upgrading from major version ${OLD_MAJOR_VERSION} to major version ${NEW_MAJOR_VERSION}."
52-
notify "It is required to upgrade to the latest ${MIN_VERSION}.x version first before proceeding."
47+
# If existing version is less than required minimum version, do not permit the upgrade.
48+
if ! greater_version $OLD_MINOR_VERSION $MIN_VERSION; then
49+
notify "It seems you are upgrading from ${OLD_MINOR_VERSION} to ${NEW_MINOR_VERSION}."
50+
notify "It is required to upgrade to the latest ${MIN_VERSION}.x version first before proceeding."
51+
52+
# If the upgrade is a major version jump, print a major upgrade notification.
53+
if test ${OLD_MAJOR_VERSION} -lt ${NEW_MAJOR_VERSION}; then
54+
notify "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/#upgrading-to-a-new-major-version"
55+
else
5356
notify "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrade-paths"
54-
exit 1
5557
fi
58+
exit 1
5659
fi
5760
fi
5861
}

docker/assets/wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ if old_version=$(cat /var/opt/gitlab/gitlab-rails/VERSION)
119119
then
120120
GITLAB_UPGRADE='true'
121121
new_version=$(awk '/^gitlab-(ce|ee|jh)/ {print $NF}' /opt/gitlab/version-manifest.txt)
122-
MIN_VERSION="15.11" gitlab-ctl upgrade-check "${old_version}" "${new_version}"
122+
gitlab-ctl upgrade-check "${old_version}" "${new_version}"
123123
fi
124124

125125
# Copy gitlab.rb for the first time

files/gitlab-ctl-commands/lib/gitlab_ctl/upgrade_check.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
module GitlabCtl
22
class UpgradeCheck
3-
MIN_VERSION = ENV['MIN_VERSION'] || '15.11'.freeze
4-
53
class <<self
6-
def valid?(ov, nv)
4+
def valid?(ov)
75
# If old_version is nil, this is a fresh install
86
return true if ov.nil?
97

10-
old_version_major = ov.split('.').first
11-
old_version_minor = ov.split('.')[0..1].join('.')
12-
new_version_major = nv.split('.').first
8+
old_version_major = ov.split('.')[0]
9+
old_version_minor = ov.split('.')[1]
10+
min_version = min_version()
11+
min_version_major = min_version.split('.')[0]
12+
min_version_minor = min_version.split('.')[1]
1313

14-
if old_version_major < new_version_major
15-
return false if old_version_minor != MIN_VERSION
16-
end
14+
minimum_version_detected = old_version_major == min_version_major && old_version_minor >= min_version_minor
15+
minimum_version_detected || old_version_major > min_version_major
16+
end
1717

18-
true
18+
def min_version
19+
ENV['MIN_VERSION'] || '16.3'.freeze
1920
end
2021
end
2122
end

files/gitlab-ctl-commands/upgrade-check.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
add_command('upgrade-check', 'Check if the upgrade is acceptable', 2) do
44
old_version = ARGV[3]
55
new_version = ARGV[4]
6-
unless GitlabCtl::UpgradeCheck.valid?(old_version, new_version)
7-
warn "It seems you are upgrading from major version #{old_version.split('.').first} to major version #{new_version.split('.').first}."
8-
warn "It is required to upgrade to the latest #{GitlabCtl::UpgradeCheck::MIN_VERSION}.x version first before proceeding."
9-
warn "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrading-to-a-new-major-version"
6+
unless GitlabCtl::UpgradeCheck.valid?(old_version)
7+
old_major = old_version.split('.').first.to_i
8+
new_major = new_version.split('.').first.to_i
9+
is_major_upgrade = new_major > old_major
10+
warn "It seems you are upgrading from #{old_version} to #{new_version}."
11+
warn "It is required to upgrade to the latest #{GitlabCtl::UpgradeCheck.min_version}.x version first before proceeding."
12+
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
13+
warn "Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/#upgrade-paths" unless is_major_upgrade
1014
Kernel.exit 1
1115
end
1216
end

spec/chef/gitlab-ctl-commands/lib/upgrade_check_spec.rb

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,44 @@
55
require 'gitlab_ctl/upgrade_check'
66

77
RSpec.describe GitlabCtl::UpgradeCheck do
8-
let(:latest) { '13.1.3' }
9-
let(:previous_major) { '12.5.10' }
10-
let(:previous_major_latest) { '12.10.13' }
11-
let(:current_major) { '13.0.8' }
12-
let(:old) { '11.5.11' }
8+
using RSpec::Parameterized::TableSyntax
139

1410
context 'not an upgrade' do
1511
it 'returns true' do
16-
expect(described_class.valid?(nil, latest)).to be true
12+
expect(described_class.valid?(nil)).to be true
1713
end
1814
end
1915

20-
context 'valid upgrade paths' do
21-
it 'returns true for an upgrade from the current major version' do
22-
expect(described_class.valid?(current_major, latest)).to be true
16+
context 'when following valid upgrade paths' do
17+
where(:old_version, :min_version) do
18+
'15.11.0' | '15.11'
19+
'15.11.0' | '15.11'
20+
'15.11.5' | '15.11'
21+
'16.3.0' | '16.3'
22+
'16.3.3' | '16.3'
23+
'17.1.0' | '16.3'
2324
end
24-
end
2525

26-
context 'invalid upgrade paths' do
27-
it 'returns false for an upgrade from 11.5 to the latest' do
28-
expect(described_class.valid?(old, latest)).to be false
26+
with_them do
27+
it "returns true" do
28+
stub_env_var('MIN_VERSION', min_version)
29+
expect(described_class.valid?(old_version)).to be true
30+
end
2931
end
32+
end
3033

31-
it 'returns false for an upgrade from 12.5 to the latest' do
32-
expect(described_class.valid?(previous_major, latest)).to be false
34+
context 'when following invalid upgrade paths' do
35+
where(:old_version, :min_version) do
36+
'15.11.0' | '16.3'
37+
'16.2.0' | '16.3'
38+
'16.2.4' | '16.3'
3339
end
3440

35-
it 'returns false upgrading from previous_major_latest to the latest' do
36-
expect(described_class.valid?(previous_major_latest, latest)).to be false
41+
with_them do
42+
it "returns false" do
43+
stub_env_var('MIN_VERSION', min_version)
44+
expect(described_class.valid?(old_version)).to be false
45+
end
3746
end
3847
end
3948
end

0 commit comments

Comments
 (0)