From be3427c9a57e0e1afde986b82b523b4fa4f75f10 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Mon, 4 Mar 2024 12:43:22 +0100 Subject: [PATCH 01/30] Maintain upgrade stop for Omnibus Relates https://gitlab.com/gitlab-org/gitlab/-/issues/420831 --- lib/release_tools.rb | 1 + .../public_release/omnibus_gitlab_release.rb | 33 +++++++-- lib/release_tools/upgrade_stop.rb | 23 ++++++ .../omnibus_gitlab_release_spec.rb | 70 +++++++++++++++++++ spec/lib/release_tools/upgrade_stop_spec.rb | 37 ++++++++++ 5 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 lib/release_tools/upgrade_stop.rb create mode 100644 spec/lib/release_tools/upgrade_stop_spec.rb diff --git a/lib/release_tools.rb b/lib/release_tools.rb index e72b6a38f5..b7874ee296 100644 --- a/lib/release_tools.rb +++ b/lib/release_tools.rb @@ -278,6 +278,7 @@ require 'release_tools/security/sync_remotes_service' require 'release_tools/security/sync_git_remotes_service' require 'release_tools/trace_section' require 'release_tools/update_gitaly_merge_request' +require 'release_tools/upgrade_stop' require 'release_tools/warning' require 'release_tools/version_client' require 'release_tools/versions' diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index d120e78fca..8a9a8b1b3b 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -18,6 +18,9 @@ module ReleaseTools Project::Kas.version_file ].freeze + PRE_INSTALL_SCRIPT = 'config/templates/package-scripts/preinst.erb' + UPGRADE_CHECK_SCRIPT = 'files/gitlab-ctl-commands/lib/gitlab_ctl/upgrade_check.rb' + def initialize( version, client: GitlabClient, @@ -49,6 +52,7 @@ module ReleaseTools compile_changelog update_component_versions + update_last_upgrade_stop ce_tag = create_ce_tag ee_tag = create_ee_tag @@ -142,6 +146,25 @@ module ReleaseTools ) end + def update_last_upgrade_stop + stop = UpgradeStop.new(version).last_required_stop + + pre_install_script = read_file(PRE_INSTALL_SCRIPT) + pre_install_script.sub!(/MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") + + upgrade_check_script = read_file(UPGRADE_CHECK_SCRIPT) + upgrade_check_script.sub!(/ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") + + commit_version_files( + target_branch, + { + PRE_INSTALL_SCRIPT => pre_install_script.to_s, + UPGRADE_CHECK_SCRIPT => upgrade_check_script.to_s + }, + message: "Update upgrade stop versions for #{version}" + ) + end + def add_release_data_for_tags(ce_tag, ee_tag) meta_version = version.to_normalized_version @@ -170,12 +193,14 @@ module ReleaseTools ) end - def read_version(project, name, branch) - content = Retriable.with_context(:api) do - client.file_contents(project, name, branch) + def read_file(file, project: project_path, branch: target_branch) + Retriable.with_context(:api) do + client.file_contents(project, file, branch).strip end + end - Version.new(content.strip) + def read_version(project, name, branch) + Version.new(read_file(name, project: project, branch: branch)) end def source_for_target_branch diff --git a/lib/release_tools/upgrade_stop.rb b/lib/release_tools/upgrade_stop.rb new file mode 100644 index 0000000000..7daae1bead --- /dev/null +++ b/lib/release_tools/upgrade_stop.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module ReleaseTools + class UpgradeStop + PATH_YAML_URL = 'https://gitlab.com/gitlab-com/support/toolbox/upgrade-path/-/raw/main/upgrade-path.yml' + + def initialize(version) + @version = Version.new(version.to_patch) + end + + def last_required_stop + response = HTTP.get(PATH_YAML_URL) + upgrade_path = YAML.safe_load(response) + + last_stop = upgrade_path + .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}.0") } + .select { |stop| stop < @version } + .max + + "#{last_stop.major}.#{last_stop.minor}" + end + end +end diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 9f82c8fb67..84d3cf5232 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -30,6 +30,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect(release).to receive(:create_target_branch) expect(release).to receive(:compile_changelog) expect(release).to receive(:update_component_versions) + expect(release).to receive(:update_last_upgrade_stop) expect(release).to receive(:create_ce_tag).and_return(ce_tag) expect(release).to receive(:create_ee_tag).and_return(ee_tag) expect(release).to receive(:notify_slack) @@ -396,4 +397,73 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do describe '#create_target_branch' do it_behaves_like 'public_release#create_target_branch' end + + describe '#update_last_upgrade_stop' do + let(:version) { ReleaseTools::OmnibusGitlabVersion.new('42.5.0.ee') } + + let(:current_upgrade_stop) { "31.0" } + + let(:expected_upgrade_stop) { "42.4" } + + let(:upgrade_check_path) { 'files/gitlab-ctl-commands/lib/gitlab_ctl/upgrade_check.rb' } + + let(:pre_install_path) { 'config/templates/package-scripts/preinst.erb' } + + let(:upgrade_path_yaml) do + <<~FILE + --- + - major: 30 + minor: 0 + - major: 42 + minor: 4 + - major: 42 + minor: 5 + - major: 42 + minor: 6 + - major: 43 + minor: 0 + FILE + end + + def pre_install_script(min_version) + <<~FILE + upgrade_check() { + MIN_VERSION=#{min_version} + } + FILE + end + + def upgrade_check_script(min_version) + <<~FILE + def min_version + ENV['MIN_VERSION'] || '#{min_version}'.freeze + end + FILE + end + + it 'commits the updated upgrade stop' do + release = described_class.new(version) + + allow(HTTP).to receive(:get).and_return(upgrade_path_yaml) + + allow(release).to receive(:read_file) + .with(pre_install_path) + .and_return(pre_install_script(current_upgrade_stop)) + + allow(release).to receive(:read_file) + .with(upgrade_check_path) + .and_return(upgrade_check_script(current_upgrade_stop)) + + expect(release).to receive(:commit_version_files).with( + '42-5-stable', + { + pre_install_path => pre_install_script(expected_upgrade_stop), + upgrade_check_path => upgrade_check_script(expected_upgrade_stop) + }, + { message: an_instance_of(String) } + ) + + release.update_last_upgrade_stop + end + end end diff --git a/spec/lib/release_tools/upgrade_stop_spec.rb b/spec/lib/release_tools/upgrade_stop_spec.rb new file mode 100644 index 0000000000..ac8508d94d --- /dev/null +++ b/spec/lib/release_tools/upgrade_stop_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe ReleaseTools::UpgradeStop do + let(:upgrade_path_yaml) do + <<~FILE + --- + - major: 30 + minor: 0 + - major: 40 + minor: 0 + FILE + end + + describe "#last_required_stop" do + using RSpec::Parameterized::TableSyntax + + where(:current_version, :expected_stop) do + "29.0.0" | nil + "30.0.0" | nil + "30.0.1" | nil + "31.0.0" | "30.0" + "39.9.9" | "30.0" + "40.0.0" | "30.0" + "40.0.1" | "30.0" + "40.1.0" | "40.0" + end + + with_them do + fit "returns the expected upgrade stop" do + allow(HTTP).to receive(:get).and_return(upgrade_path_yaml) + + expect(described_class.new(ReleaseTools::Version.new(current_version)).last_required_stop) + .to eq(expected_stop) + end + end + end +end -- GitLab From 015f1a0d0d97439c112411b24ff2ddde5a6ec4e1 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 6 Mar 2024 16:29:03 +0100 Subject: [PATCH 02/30] Seperate release and lib specs --- lib/release_tools/upgrade_stop.rb | 6 ++-- .../omnibus_gitlab_release_spec.rb | 28 +++++++------------ spec/lib/release_tools/upgrade_stop_spec.rb | 4 ++- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/release_tools/upgrade_stop.rb b/lib/release_tools/upgrade_stop.rb index 7daae1bead..836ef8375e 100644 --- a/lib/release_tools/upgrade_stop.rb +++ b/lib/release_tools/upgrade_stop.rb @@ -5,7 +5,7 @@ module ReleaseTools PATH_YAML_URL = 'https://gitlab.com/gitlab-com/support/toolbox/upgrade-path/-/raw/main/upgrade-path.yml' def initialize(version) - @version = Version.new(version.to_patch) + @version = Version.new(version.to_minor) end def last_required_stop @@ -13,10 +13,12 @@ module ReleaseTools upgrade_path = YAML.safe_load(response) last_stop = upgrade_path - .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}.0") } + .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}") } .select { |stop| stop < @version } .max + return nil if last_stop.nil? + "#{last_stop.major}.#{last_stop.minor}" end end diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 84d3cf5232..a68db23b95 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -409,22 +409,6 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do let(:pre_install_path) { 'config/templates/package-scripts/preinst.erb' } - let(:upgrade_path_yaml) do - <<~FILE - --- - - major: 30 - minor: 0 - - major: 42 - minor: 4 - - major: 42 - minor: 5 - - major: 42 - minor: 6 - - major: 43 - minor: 0 - FILE - end - def pre_install_script(min_version) <<~FILE upgrade_check() { @@ -442,9 +426,17 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do end it 'commits the updated upgrade stop' do - release = described_class.new(version) + upgrade_stop_spy = instance_spy(ReleaseTools::UpgradeStop) - allow(HTTP).to receive(:get).and_return(upgrade_path_yaml) + expect(ReleaseTools::UpgradeStop) + .to receive(:new) + .and_return(upgrade_stop_spy) + + expect(upgrade_stop_spy) + .to receive(:last_required_stop) + .and_return(expected_upgrade_stop) + + release = described_class.new(version) allow(release).to receive(:read_file) .with(pre_install_path) diff --git a/spec/lib/release_tools/upgrade_stop_spec.rb b/spec/lib/release_tools/upgrade_stop_spec.rb index ac8508d94d..b08bd23e46 100644 --- a/spec/lib/release_tools/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/upgrade_stop_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe ReleaseTools::UpgradeStop do @@ -26,7 +28,7 @@ describe ReleaseTools::UpgradeStop do end with_them do - fit "returns the expected upgrade stop" do + it "returns the expected upgrade stop" do allow(HTTP).to receive(:get).and_return(upgrade_path_yaml) expect(described_class.new(ReleaseTools::Version.new(current_version)).last_required_stop) -- GitLab From 649b99060162368447200a5604d2243baf3dfc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Alexandre=20Cunha?= Date: Tue, 19 Mar 2024 22:46:35 +0000 Subject: [PATCH 03/30] Apply code style suggestions --- lib/release_tools/upgrade_stop.rb | 4 +--- .../public_release/omnibus_gitlab_release_spec.rb | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/release_tools/upgrade_stop.rb b/lib/release_tools/upgrade_stop.rb index 836ef8375e..c36eb122ca 100644 --- a/lib/release_tools/upgrade_stop.rb +++ b/lib/release_tools/upgrade_stop.rb @@ -17,9 +17,7 @@ module ReleaseTools .select { |stop| stop < @version } .max - return nil if last_stop.nil? - - "#{last_stop.major}.#{last_stop.minor}" + "#{last_stop.major}.#{last_stop.minor}" if last_stop end end end diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index a68db23b95..ce0ed6cb20 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -400,13 +400,9 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do describe '#update_last_upgrade_stop' do let(:version) { ReleaseTools::OmnibusGitlabVersion.new('42.5.0.ee') } - let(:current_upgrade_stop) { "31.0" } - let(:expected_upgrade_stop) { "42.4" } - let(:upgrade_check_path) { 'files/gitlab-ctl-commands/lib/gitlab_ctl/upgrade_check.rb' } - let(:pre_install_path) { 'config/templates/package-scripts/preinst.erb' } def pre_install_script(min_version) -- GitLab From 65a764e6c337d63e49e5f834358788f3daeb1c05 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 19 Mar 2024 23:58:19 +0100 Subject: [PATCH 04/30] Make min version regex more assertive MIN_VERSION is either at the beginning of the line or preceded by a whitespace character, so it does never matches PG_MIN_VERSION. --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- .../release_tools/public_release/omnibus_gitlab_release_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 8a9a8b1b3b..2b1c8f2ef7 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -150,7 +150,7 @@ module ReleaseTools stop = UpgradeStop.new(version).last_required_stop pre_install_script = read_file(PRE_INSTALL_SCRIPT) - pre_install_script.sub!(/MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") + pre_install_script.sub!(/(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") upgrade_check_script = read_file(UPGRADE_CHECK_SCRIPT) upgrade_check_script.sub!(/ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index ce0ed6cb20..24f38bedba 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -408,6 +408,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do def pre_install_script(min_version) <<~FILE upgrade_check() { + PG_MIN_VERSION=10.1 MIN_VERSION=#{min_version} } FILE -- GitLab From 1eaf00e0ea3b994e31061a46a4f0bfe4e2c35a0b Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 20 Mar 2024 01:00:42 +0100 Subject: [PATCH 05/30] Move upgrade_stop.rb to public_release/upgrade_stop.rb --- lib/release_tools.rb | 2 +- lib/release_tools/{ => public_release}/upgrade_stop.rb | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/release_tools/{ => public_release}/upgrade_stop.rb (100%) diff --git a/lib/release_tools.rb b/lib/release_tools.rb index b7874ee296..c9175cd4a5 100644 --- a/lib/release_tools.rb +++ b/lib/release_tools.rb @@ -205,6 +205,7 @@ require 'release_tools/public_release/gitaly_master_release' require 'release_tools/public_release/gitaly_monthly_release' require 'release_tools/public_release/cng_image_release' require 'release_tools/public_release/helm_gitlab_release' +require 'release_tools/public_release/upgrade_stop' require 'release_tools/release_managers/client' require 'release_tools/release_managers/slack_client' require 'release_tools/release_managers/definitions' @@ -278,7 +279,6 @@ require 'release_tools/security/sync_remotes_service' require 'release_tools/security/sync_git_remotes_service' require 'release_tools/trace_section' require 'release_tools/update_gitaly_merge_request' -require 'release_tools/upgrade_stop' require 'release_tools/warning' require 'release_tools/version_client' require 'release_tools/versions' diff --git a/lib/release_tools/upgrade_stop.rb b/lib/release_tools/public_release/upgrade_stop.rb similarity index 100% rename from lib/release_tools/upgrade_stop.rb rename to lib/release_tools/public_release/upgrade_stop.rb -- GitLab From cb556f5dd24af1e8199825bbb6fddb73e56fcaa7 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 20 Mar 2024 16:17:00 +0100 Subject: [PATCH 06/30] Introduce feature flag to maintain upgrade stops --- .../public_release/omnibus_gitlab_release.rb | 2 + .../omnibus_gitlab_release_spec.rb | 68 ++++++++++++------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 2b1c8f2ef7..b647f48c42 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -147,6 +147,8 @@ module ReleaseTools end def update_last_upgrade_stop + return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) + stop = UpgradeStop.new(version).last_required_stop pre_install_script = read_file(PRE_INSTALL_SCRIPT) diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 24f38bedba..68b8bdd653 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -422,37 +422,57 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do FILE end - it 'commits the updated upgrade stop' do - upgrade_stop_spy = instance_spy(ReleaseTools::UpgradeStop) + context 'feature flag is disabled' do + before do + disable_feature(:maintain_upgrade_stops) + end - expect(ReleaseTools::UpgradeStop) - .to receive(:new) - .and_return(upgrade_stop_spy) + it 'does not update the upgrade stop' do + expect(ReleaseTools::UpgradeStop) + .not_to receive(:new) - expect(upgrade_stop_spy) - .to receive(:last_required_stop) - .and_return(expected_upgrade_stop) + release = described_class.new(version) + release.update_last_upgrade_stop + end + end - release = described_class.new(version) + context 'feature flag is enabled' do + before do + enable_feature(:maintain_upgrade_stops) + end - allow(release).to receive(:read_file) - .with(pre_install_path) - .and_return(pre_install_script(current_upgrade_stop)) + it 'commits the updated upgrade stop' do + upgrade_stop_spy = instance_spy(ReleaseTools::UpgradeStop) - allow(release).to receive(:read_file) - .with(upgrade_check_path) - .and_return(upgrade_check_script(current_upgrade_stop)) + expect(ReleaseTools::UpgradeStop) + .to receive(:new) + .and_return(upgrade_stop_spy) - expect(release).to receive(:commit_version_files).with( - '42-5-stable', - { - pre_install_path => pre_install_script(expected_upgrade_stop), - upgrade_check_path => upgrade_check_script(expected_upgrade_stop) - }, - { message: an_instance_of(String) } - ) + expect(upgrade_stop_spy) + .to receive(:last_required_stop) + .and_return(expected_upgrade_stop) + + release = described_class.new(version) - release.update_last_upgrade_stop + allow(release).to receive(:read_file) + .with(pre_install_path) + .and_return(pre_install_script(current_upgrade_stop)) + + allow(release).to receive(:read_file) + .with(upgrade_check_path) + .and_return(upgrade_check_script(current_upgrade_stop)) + + expect(release).to receive(:commit_version_files).with( + '42-5-stable', + { + pre_install_path => pre_install_script(expected_upgrade_stop), + upgrade_check_path => upgrade_check_script(expected_upgrade_stop) + }, + { message: an_instance_of(String) } + ) + + release.update_last_upgrade_stop + end end end end -- GitLab From 4190113e5f64cb943ef93046497ec7083d7c075f Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 21 Mar 2024 09:36:02 +0100 Subject: [PATCH 07/30] Create upgrade stop commit with GitlabClient --- .../public_release/omnibus_gitlab_release.rb | 26 +++++++++++++------ .../omnibus_gitlab_release_spec.rb | 13 +++++----- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index b647f48c42..ee1ab2946c 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -157,14 +157,24 @@ module ReleaseTools upgrade_check_script = read_file(UPGRADE_CHECK_SCRIPT) upgrade_check_script.sub!(/ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") - commit_version_files( - target_branch, - { - PRE_INSTALL_SCRIPT => pre_install_script.to_s, - UPGRADE_CHECK_SCRIPT => upgrade_check_script.to_s - }, - message: "Update upgrade stop versions for #{version}" - ) + Retriable.with_context(:api) do + GitlabClient.create_commit( + project_path, + target_branch, + "Update upgrade stop to #{stop}", + [ + { + action: 'update', + file_path: PRE_INSTALL_SCRIPT, + content: pre_install_script.to_s + }, { + action: 'update', + file_path: UPGRADE_CHECK_SCRIPT, + content: upgrade_check_script.to_s + } + ] + ) + end end def add_release_data_for_tags(ce_tag, ee_tag) diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 68b8bdd653..6da1d2efa6 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -462,13 +462,14 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do .with(upgrade_check_path) .and_return(upgrade_check_script(current_upgrade_stop)) - expect(release).to receive(:commit_version_files).with( + expect(GitlabClient).to receive(create_commit).with( + release.project_path, '42-5-stable', - { - pre_install_path => pre_install_script(expected_upgrade_stop), - upgrade_check_path => upgrade_check_script(expected_upgrade_stop) - }, - { message: an_instance_of(String) } + an_instance_of(String), + [ + { action: 'update', file_path: pre_install_path, content: pre_install_script(expected_upgrade_stop) }, + { action: 'update', file_path: upgrade_check_path, content: upgrade_check_script(expected_upgrade_stop) } + ] ) release.update_last_upgrade_stop -- GitLab From 2d9f7268e842619cff052030a4175cc5aece02d0 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 21 Mar 2024 09:41:18 +0100 Subject: [PATCH 08/30] Extend upgrade stop specs --- spec/lib/release_tools/upgrade_stop_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/lib/release_tools/upgrade_stop_spec.rb b/spec/lib/release_tools/upgrade_stop_spec.rb index b08bd23e46..b304b8d4b8 100644 --- a/spec/lib/release_tools/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/upgrade_stop_spec.rb @@ -10,6 +10,10 @@ describe ReleaseTools::UpgradeStop do minor: 0 - major: 40 minor: 0 + - major: 40 + minor: 5 + - major: 40 + minor: 10 FILE end @@ -25,6 +29,11 @@ describe ReleaseTools::UpgradeStop do "40.0.0" | "30.0" "40.0.1" | "30.0" "40.1.0" | "40.0" + "40.5.0" | "40.0" + "40.5.1" | "40.0" + "40.6.0" | "40.5" + "40.10.0" | "40.5" + "40.11.0" | "40.10" end with_them do -- GitLab From 4468af7a317ba59ed75bbff263eaaf441930a551 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 21 Mar 2024 10:31:52 +0100 Subject: [PATCH 09/30] Fetch upgrade path via gitlab client --- .../public_release/upgrade_stop.rb | 17 ++++++++++++----- spec/lib/release_tools/upgrade_stop_spec.rb | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/release_tools/public_release/upgrade_stop.rb b/lib/release_tools/public_release/upgrade_stop.rb index c36eb122ca..7f35343739 100644 --- a/lib/release_tools/public_release/upgrade_stop.rb +++ b/lib/release_tools/public_release/upgrade_stop.rb @@ -2,22 +2,29 @@ module ReleaseTools class UpgradeStop - PATH_YAML_URL = 'https://gitlab.com/gitlab-com/support/toolbox/upgrade-path/-/raw/main/upgrade-path.yml' + UPGRADE_PATH_PROJECT_ID = "29943108" # https://gitlab.com/gitlab-com/support/toolbox/upgrade-path + UPGRADE_PATH_FILE = "upgrade-path.yml" + UPGRADE_PATH_BRANCH = "main" def initialize(version) @version = Version.new(version.to_minor) end def last_required_stop - response = HTTP.get(PATH_YAML_URL) - upgrade_path = YAML.safe_load(response) - - last_stop = upgrade_path + last_stop = upgrade_path_hash .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}") } .select { |stop| stop < @version } .max "#{last_stop.major}.#{last_stop.minor}" if last_stop end + + private + + def upgrade_path_hash + response = ReleaseTools::GitlabClient.get_file(UPGRADE_PATH_PROJECT_ID, UPGRADE_PATH_FILE, UPGRADE_PATH_BRANCH) + content = Base64.strict_decode64(response.content) + YAML.safe_load(content) + end end end diff --git a/spec/lib/release_tools/upgrade_stop_spec.rb b/spec/lib/release_tools/upgrade_stop_spec.rb index b304b8d4b8..676557f192 100644 --- a/spec/lib/release_tools/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/upgrade_stop_spec.rb @@ -38,7 +38,9 @@ describe ReleaseTools::UpgradeStop do with_them do it "returns the expected upgrade stop" do - allow(HTTP).to receive(:get).and_return(upgrade_path_yaml) + allow(ReleaseTools::GitlabClient) + .to receive(:get_file) + .and_return(build(:gitlab_response, content: Base64.strict_encode64(upgrade_path_yaml))) expect(described_class.new(ReleaseTools::Version.new(current_version)).last_required_stop) .to eq(expected_stop) -- GitLab From 6f462ef87dd8598701cef40d7741d8c13a285ce4 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 21 Mar 2024 10:51:14 +0100 Subject: [PATCH 10/30] Fix client call to create upgrade stop commit --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- .../release_tools/public_release/omnibus_gitlab_release_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index ee1ab2946c..b6baea41b6 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -158,7 +158,7 @@ module ReleaseTools upgrade_check_script.sub!(/ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") Retriable.with_context(:api) do - GitlabClient.create_commit( + client.create_commit( project_path, target_branch, "Update upgrade stop to #{stop}", diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 6da1d2efa6..b84030a7f3 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -462,7 +462,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do .with(upgrade_check_path) .and_return(upgrade_check_script(current_upgrade_stop)) - expect(GitlabClient).to receive(create_commit).with( + expect(release.client).to receive(:create_commit).with( release.project_path, '42-5-stable', an_instance_of(String), -- GitLab From ef3cff2b59f9844ee48f4e6b619e52a6dfac318f Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 28 Mar 2024 11:27:27 +0100 Subject: [PATCH 11/30] Raise error if scripts don't match --- .../public_release/omnibus_gitlab_release.rb | 14 +++++++---- .../omnibus_gitlab_release_spec.rb | 24 ++++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index b6baea41b6..cc06813f4a 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -151,11 +151,8 @@ module ReleaseTools stop = UpgradeStop.new(version).last_required_stop - pre_install_script = read_file(PRE_INSTALL_SCRIPT) - pre_install_script.sub!(/(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") - - upgrade_check_script = read_file(UPGRADE_CHECK_SCRIPT) - upgrade_check_script.sub!(/ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") + pre_install_script = change_min_version!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") + upgrade_check_script = change_min_version!(UPGRADE_CHECK_SCRIPT, /ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") Retriable.with_context(:api) do client.create_commit( @@ -177,6 +174,13 @@ module ReleaseTools end end + def change_min_version!(filename, regexp, replacement) + content = read_file(filename) + raise "The regexp '#{regexp}' does not match in #{filename}" unless regexp.match?(content) + + content.sub(regexp, replacement) + end + def add_release_data_for_tags(ce_tag, ee_tag) meta_version = version.to_normalized_version diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index b84030a7f3..f46f753c96 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -437,11 +437,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do end context 'feature flag is enabled' do - before do - enable_feature(:maintain_upgrade_stops) - end - - it 'commits the updated upgrade stop' do + let(:release) do upgrade_stop_spy = instance_spy(ReleaseTools::UpgradeStop) expect(ReleaseTools::UpgradeStop) @@ -452,8 +448,14 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do .to receive(:last_required_stop) .and_return(expected_upgrade_stop) - release = described_class.new(version) + described_class.new(version) + end + + before do + enable_feature(:maintain_upgrade_stops) + end + it 'commits the updated upgrade stop' do allow(release).to receive(:read_file) .with(pre_install_path) .and_return(pre_install_script(current_upgrade_stop)) @@ -474,6 +476,16 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do release.update_last_upgrade_stop end + + context 'file does not match the expected regular expression' do + it 'raises an error' do + allow(release).to receive(:read_file) + .with(pre_install_path) + .and_return("foobar") + + expect { release.update_last_upgrade_stop }.to raise_error(/does not match/) + end + end end end end -- GitLab From 59c30c2c111730562fbcc5c0c55b7d31b4b1c804 Mon Sep 17 00:00:00 2001 From: Peter Leitzen Date: Thu, 28 Mar 2024 10:28:34 +0000 Subject: [PATCH 12/30] Remove unnecessary 'to_s' calls --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index cc06813f4a..18bfd40854 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -163,11 +163,11 @@ module ReleaseTools { action: 'update', file_path: PRE_INSTALL_SCRIPT, - content: pre_install_script.to_s + content: pre_install_script }, { action: 'update', file_path: UPGRADE_CHECK_SCRIPT, - content: upgrade_check_script.to_s + content: upgrade_check_script } ] ) -- GitLab From 72b561ba2a38df7c163c307fac7acca566aac270 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Mon, 8 Apr 2024 16:42:39 +0200 Subject: [PATCH 13/30] Move UpgradeStop to PublicRelease module --- lib/release_tools/public_release/upgrade_stop.rb | 2 +- .../public_release/omnibus_gitlab_release_spec.rb | 6 +++--- .../release_tools/{ => public_release}/upgrade_stop_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename spec/lib/release_tools/{ => public_release}/upgrade_stop_spec.rb (96%) diff --git a/lib/release_tools/public_release/upgrade_stop.rb b/lib/release_tools/public_release/upgrade_stop.rb index 7f35343739..385e9d5944 100644 --- a/lib/release_tools/public_release/upgrade_stop.rb +++ b/lib/release_tools/public_release/upgrade_stop.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module ReleaseTools +module PublicRelease class UpgradeStop UPGRADE_PATH_PROJECT_ID = "29943108" # https://gitlab.com/gitlab-com/support/toolbox/upgrade-path UPGRADE_PATH_FILE = "upgrade-path.yml" diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index f46f753c96..91b2363c78 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -428,7 +428,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do end it 'does not update the upgrade stop' do - expect(ReleaseTools::UpgradeStop) + expect(PublicRelease::UpgradeStop) .not_to receive(:new) release = described_class.new(version) @@ -438,9 +438,9 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do context 'feature flag is enabled' do let(:release) do - upgrade_stop_spy = instance_spy(ReleaseTools::UpgradeStop) + upgrade_stop_spy = instance_spy(PublicRelease::UpgradeStop) - expect(ReleaseTools::UpgradeStop) + expect(PublicRelease::UpgradeStop) .to receive(:new) .and_return(upgrade_stop_spy) diff --git a/spec/lib/release_tools/upgrade_stop_spec.rb b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb similarity index 96% rename from spec/lib/release_tools/upgrade_stop_spec.rb rename to spec/lib/release_tools/public_release/upgrade_stop_spec.rb index 676557f192..3afd1a7ddc 100644 --- a/spec/lib/release_tools/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ReleaseTools::UpgradeStop do +describe PublicRelease::UpgradeStop do let(:upgrade_path_yaml) do <<~FILE --- -- GitLab From 9f398e7f89208eee99b3e5ce779cabd565863cbe Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Mon, 8 Apr 2024 17:16:36 +0200 Subject: [PATCH 14/30] Fixup upgrade stop module --- .../public_release/upgrade_stop.rb | 42 ++++++++++--------- .../omnibus_gitlab_release_spec.rb | 6 +-- .../public_release/upgrade_stop_spec.rb | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/release_tools/public_release/upgrade_stop.rb b/lib/release_tools/public_release/upgrade_stop.rb index 385e9d5944..45785355fe 100644 --- a/lib/release_tools/public_release/upgrade_stop.rb +++ b/lib/release_tools/public_release/upgrade_stop.rb @@ -1,30 +1,32 @@ # frozen_string_literal: true -module PublicRelease - class UpgradeStop - UPGRADE_PATH_PROJECT_ID = "29943108" # https://gitlab.com/gitlab-com/support/toolbox/upgrade-path - UPGRADE_PATH_FILE = "upgrade-path.yml" - UPGRADE_PATH_BRANCH = "main" +module ReleaseTools + module PublicRelease + class UpgradeStop + UPGRADE_PATH_PROJECT_ID = "29943108" # https://gitlab.com/gitlab-com/support/toolbox/upgrade-path + UPGRADE_PATH_FILE = "upgrade-path.yml" + UPGRADE_PATH_BRANCH = "main" - def initialize(version) - @version = Version.new(version.to_minor) - end + def initialize(version) + @version = Version.new(version.to_minor) + end - def last_required_stop - last_stop = upgrade_path_hash - .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}") } - .select { |stop| stop < @version } - .max + def last_required_stop + last_stop = upgrade_path_hash + .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}") } + .select { |stop| stop < @version } + .max - "#{last_stop.major}.#{last_stop.minor}" if last_stop - end + "#{last_stop.major}.#{last_stop.minor}" if last_stop + end - private + private - def upgrade_path_hash - response = ReleaseTools::GitlabClient.get_file(UPGRADE_PATH_PROJECT_ID, UPGRADE_PATH_FILE, UPGRADE_PATH_BRANCH) - content = Base64.strict_decode64(response.content) - YAML.safe_load(content) + def upgrade_path_hash + response = ReleaseTools::GitlabClient.get_file(UPGRADE_PATH_PROJECT_ID, UPGRADE_PATH_FILE, UPGRADE_PATH_BRANCH) + content = Base64.strict_decode64(response.content) + YAML.safe_load(content) + end end end end diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 91b2363c78..a7c79421d4 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -428,7 +428,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do end it 'does not update the upgrade stop' do - expect(PublicRelease::UpgradeStop) + expect(ReleaseTools::PublicRelease::UpgradeStop) .not_to receive(:new) release = described_class.new(version) @@ -438,9 +438,9 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do context 'feature flag is enabled' do let(:release) do - upgrade_stop_spy = instance_spy(PublicRelease::UpgradeStop) + upgrade_stop_spy = instance_spy(ReleaseTools::PublicRelease::UpgradeStop) - expect(PublicRelease::UpgradeStop) + expect(ReleaseTools::PublicRelease::UpgradeStop) .to receive(:new) .and_return(upgrade_stop_spy) diff --git a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb index 3afd1a7ddc..7f7ff419b8 100644 --- a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe PublicRelease::UpgradeStop do +describe ReleaseTools::PublicRelease::UpgradeStop do let(:upgrade_path_yaml) do <<~FILE --- -- GitLab From 4af11ffb404de711bb806fcea586206daa1b6d49 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 9 Apr 2024 15:50:12 +0200 Subject: [PATCH 15/30] Refactor specs to use test subject --- spec/lib/release_tools/public_release/upgrade_stop_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb index 7f7ff419b8..943e19f285 100644 --- a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe ReleaseTools::PublicRelease::UpgradeStop do + subject(:upgrade_stop) { described_class.new(ReleaseTools::Version.new(current_version)) } + let(:upgrade_path_yaml) do <<~FILE --- @@ -42,8 +44,7 @@ describe ReleaseTools::PublicRelease::UpgradeStop do .to receive(:get_file) .and_return(build(:gitlab_response, content: Base64.strict_encode64(upgrade_path_yaml))) - expect(described_class.new(ReleaseTools::Version.new(current_version)).last_required_stop) - .to eq(expected_stop) + expect(upgrade_stop.last_required_stop).to eq(expected_stop) end end end -- GitLab From 1fa98b48409705e611718bb9e687c0621e074095 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 9 Apr 2024 15:56:13 +0200 Subject: [PATCH 16/30] Log detected upgrade stop --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 18bfd40854..fab680815a 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -150,6 +150,7 @@ module ReleaseTools return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) stop = UpgradeStop.new(version).last_required_stop + logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) pre_install_script = change_min_version!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") upgrade_check_script = change_min_version!(UPGRADE_CHECK_SCRIPT, /ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") -- GitLab From 200d29a407564eafce2820646007c262f92ef1d3 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 9 Apr 2024 16:00:53 +0200 Subject: [PATCH 17/30] Skip CI for upgrade stop commit --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index fab680815a..3617b6cc1b 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -159,7 +159,7 @@ module ReleaseTools client.create_commit( project_path, target_branch, - "Update upgrade stop to #{stop}", + "Update upgrade stop to #{stop}\n\n[ci skip]", [ { action: 'update', -- GitLab From ecca342fcc9ecca88b43732ed398c81fb6c923dc Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 9 Apr 2024 16:09:18 +0200 Subject: [PATCH 18/30] Tweak upgrade stop test case Customize the test set to ensure that versions are compared as semantic versions and not as strings. --- .../public_release/upgrade_stop_spec.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb index 943e19f285..4491831f00 100644 --- a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb @@ -13,9 +13,11 @@ describe ReleaseTools::PublicRelease::UpgradeStop do - major: 40 minor: 0 - major: 40 - minor: 5 + minor: 9 - major: 40 minor: 10 + - major: 40 + minor: 11 FILE end @@ -31,10 +33,11 @@ describe ReleaseTools::PublicRelease::UpgradeStop do "40.0.0" | "30.0" "40.0.1" | "30.0" "40.1.0" | "40.0" - "40.5.0" | "40.0" - "40.5.1" | "40.0" - "40.6.0" | "40.5" - "40.10.0" | "40.5" + "40.8.0" | "40.0" + "40.8.1" | "40.0" + "40.10.0" | "40.9" + "40.11.0" | "40.10" + "40.12.0" | "40.11" "40.11.0" | "40.10" end -- GitLab From 7e2cc5f74fbb9028b6b0d7410320576cc70bcbe7 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 9 Apr 2024 16:56:34 +0200 Subject: [PATCH 19/30] Do not commit if upgrade stop is up to date --- .../public_release/omnibus_gitlab_release.rb | 37 +++++++++++-------- .../omnibus_gitlab_release_spec.rb | 19 ++++++++++ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 3617b6cc1b..e9f1876406 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -150,36 +150,41 @@ module ReleaseTools return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) stop = UpgradeStop.new(version).last_required_stop - logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) + logger.info('Last reqiuired stop for version detected', version: version.to_minor, last_required_stop: stop) - pre_install_script = change_min_version!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") - upgrade_check_script = change_min_version!(UPGRADE_CHECK_SCRIPT, /ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") + actions = [] + actions << change_upgrade_stop_action!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") + actions << change_upgrade_stop_action!(UPGRADE_CHECK_SCRIPT, /ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") + actions.compact! + + if actions.empty? + logger.info('Nothing to be done to apply upgrade stop to Omnibus', version: version.to_minor, last_required_stop: stop) + return + end Retriable.with_context(:api) do client.create_commit( project_path, target_branch, "Update upgrade stop to #{stop}\n\n[ci skip]", - [ - { - action: 'update', - file_path: PRE_INSTALL_SCRIPT, - content: pre_install_script - }, { - action: 'update', - file_path: UPGRADE_CHECK_SCRIPT, - content: upgrade_check_script - } - ] + actions ) end end - def change_min_version!(filename, regexp, replacement) + def change_upgrade_stop_action!(filename, regexp, replacement) content = read_file(filename) raise "The regexp '#{regexp}' does not match in #{filename}" unless regexp.match?(content) - content.sub(regexp, replacement) + new_content = content.sub(regexp, replacement) + + return nil if content == new_content + + { + action: 'update', + file_path: filename, + content: new_content + } end def add_release_data_for_tags(ce_tag, ee_tag) diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index a7c79421d4..997d6c3544 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -486,6 +486,25 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect { release.update_last_upgrade_stop }.to raise_error(/does not match/) end end + + context 'upgrade stop is already up to date' do + let(:current_upgrade_stop) { "31.0" } + let(:expected_upgrade_stop) { "31.0" } + + it 'does not create a commit' do + allow(release).to receive(:read_file) + .with(pre_install_path) + .and_return(pre_install_script(current_upgrade_stop)) + + allow(release).to receive(:read_file) + .with(upgrade_check_path) + .and_return(upgrade_check_script(current_upgrade_stop)) + + expect(release.client).not_to receive(:create_commit) + + release.update_last_upgrade_stop + end + end end end end -- GitLab From 8cab640342ca2738b7f4b213ca6ea56a93543f32 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 11 Apr 2024 13:50:29 +0200 Subject: [PATCH 20/30] Wrap upgrade stop query in a retrieable --- lib/release_tools/public_release/upgrade_stop.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/upgrade_stop.rb b/lib/release_tools/public_release/upgrade_stop.rb index 45785355fe..96b85c574b 100644 --- a/lib/release_tools/public_release/upgrade_stop.rb +++ b/lib/release_tools/public_release/upgrade_stop.rb @@ -23,7 +23,11 @@ module ReleaseTools private def upgrade_path_hash - response = ReleaseTools::GitlabClient.get_file(UPGRADE_PATH_PROJECT_ID, UPGRADE_PATH_FILE, UPGRADE_PATH_BRANCH) + response = Retriable.with_context(:api) do + ReleaseTools::GitlabClient + .get_file(UPGRADE_PATH_PROJECT_ID, UPGRADE_PATH_FILE, UPGRADE_PATH_BRANCH) + end + content = Base64.strict_decode64(response.content) YAML.safe_load(content) end -- GitLab From 18d405a5bf7d71c85a24ca7ab3fac557aaf64f9c Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 16 Apr 2024 13:09:26 +0200 Subject: [PATCH 21/30] Move spy setup from let to spec --- .../public_release/omnibus_gitlab_release_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 997d6c3544..ee4626a57e 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -438,6 +438,10 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do context 'feature flag is enabled' do let(:release) do + described_class.new(version) + end + + def expect_new_upgrade_stop upgrade_stop_spy = instance_spy(ReleaseTools::PublicRelease::UpgradeStop) expect(ReleaseTools::PublicRelease::UpgradeStop) @@ -447,8 +451,6 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect(upgrade_stop_spy) .to receive(:last_required_stop) .and_return(expected_upgrade_stop) - - described_class.new(version) end before do @@ -456,6 +458,8 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do end it 'commits the updated upgrade stop' do + expect_new_upgrade_stop + allow(release).to receive(:read_file) .with(pre_install_path) .and_return(pre_install_script(current_upgrade_stop)) @@ -479,6 +483,8 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do context 'file does not match the expected regular expression' do it 'raises an error' do + expect_new_upgrade_stop + allow(release).to receive(:read_file) .with(pre_install_path) .and_return("foobar") @@ -492,6 +498,8 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do let(:expected_upgrade_stop) { "31.0" } it 'does not create a commit' do + expect_new_upgrade_stop + allow(release).to receive(:read_file) .with(pre_install_path) .and_return(pre_install_script(current_upgrade_stop)) -- GitLab From c30d9174c5d8d0216fa1f3e9416ed41c76d52189 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Tue, 16 Apr 2024 11:11:07 +0000 Subject: [PATCH 22/30] Fix typo in log message --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index e9f1876406..ba7b9d00bd 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -150,7 +150,7 @@ module ReleaseTools return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) stop = UpgradeStop.new(version).last_required_stop - logger.info('Last reqiuired stop for version detected', version: version.to_minor, last_required_stop: stop) + logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) actions = [] actions << change_upgrade_stop_action!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") -- GitLab From 7f3da301f02e039a42047d9d8974e75d1cdffade Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 18 Apr 2024 11:58:50 +0200 Subject: [PATCH 23/30] Skip upgrade stop update on patch release --- .../public_release/omnibus_gitlab_release.rb | 5 +++++ .../omnibus_gitlab_release_spec.rb | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index ba7b9d00bd..54b61f30c9 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -149,6 +149,11 @@ module ReleaseTools def update_last_upgrade_stop return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) + if version.patch? + logger.info('Patch release detected, not updating the Omnibus upgrade stop.', version: version) + return + end + stop = UpgradeStop.new(version).last_required_stop logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index ee4626a57e..79d4124489 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -422,12 +422,8 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do FILE end - context 'feature flag is disabled' do - before do - disable_feature(:maintain_upgrade_stops) - end - - it 'does not update the upgrade stop' do + shared_examples 'upgrade stop is not updated' do + it 'does not check for the upgrade stop' do expect(ReleaseTools::PublicRelease::UpgradeStop) .not_to receive(:new) @@ -436,6 +432,14 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do end end + context 'feature flag is disabled' do + before do + disable_feature(:maintain_upgrade_stops) + end + + include_examples 'upgrade stop is not updated' + end + context 'feature flag is enabled' do let(:release) do described_class.new(version) @@ -513,6 +517,12 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do release.update_last_upgrade_stop end end + + context 'on a patch release' do + let(:version) { ReleaseTools::OmnibusGitlabVersion.new('42.5.1.ee') } + + include_examples 'upgrade stop is not updated' + end end end end -- GitLab From e426ace0fa1497224b8b1b33d5d53881794d1919 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 24 Apr 2024 08:21:43 +0000 Subject: [PATCH 24/30] Refine log message --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 54b61f30c9..05c248ff2b 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -150,7 +150,7 @@ module ReleaseTools return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) if version.patch? - logger.info('Patch release detected, not updating the Omnibus upgrade stop.', version: version) + logger.info('Patch release or release candidate detected, skipping the Omnibus upgrade stop', version: version) return end -- GitLab From d15352f9fcb3c8dae0733f1377248daba99af215 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 24 Apr 2024 10:27:40 +0200 Subject: [PATCH 25/30] Skip upgrade stop update on release candidate --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- .../public_release/omnibus_gitlab_release_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 05c248ff2b..b7ad03d3dd 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -149,7 +149,7 @@ module ReleaseTools def update_last_upgrade_stop return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) - if version.patch? + if version.patch? || version.rc? logger.info('Patch release or release candidate detected, skipping the Omnibus upgrade stop', version: version) return end diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 79d4124489..33a8ec4c62 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -523,6 +523,12 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do include_examples 'upgrade stop is not updated' end + + context 'on a release candicate' do + let(:version) { ReleaseTools::OmnibusGitlabVersion.new('42.5.0-rc1') } + + include_examples 'upgrade stop is not updated' + end end end end -- GitLab From 47a2e64742bb1664d6e5cc6f1bea71990f8c5654 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 24 Apr 2024 10:35:31 +0200 Subject: [PATCH 26/30] Catch and log error during upgrade stop --- .../public_release/omnibus_gitlab_release.rb | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index b7ad03d3dd..2e2eb57cb7 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -154,26 +154,32 @@ module ReleaseTools return end - stop = UpgradeStop.new(version).last_required_stop - logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) - - actions = [] - actions << change_upgrade_stop_action!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") - actions << change_upgrade_stop_action!(UPGRADE_CHECK_SCRIPT, /ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") - actions.compact! - - if actions.empty? - logger.info('Nothing to be done to apply upgrade stop to Omnibus', version: version.to_minor, last_required_stop: stop) - return - end - - Retriable.with_context(:api) do - client.create_commit( - project_path, - target_branch, - "Update upgrade stop to #{stop}\n\n[ci skip]", - actions - ) + begin + stop = UpgradeStop.new(version).last_required_stop + logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) + + actions = [] + actions << change_upgrade_stop_action!(PRE_INSTALL_SCRIPT, /(?<=[\s]|^)MIN_VERSION=[^\n]*/, "MIN_VERSION=#{stop}") + actions << change_upgrade_stop_action!(UPGRADE_CHECK_SCRIPT, /ENV\['MIN_VERSION'\] [\|]{2} '[0-9.]*'/, "ENV['MIN_VERSION'] || '#{stop}'") + actions.compact! + + if actions.empty? + logger.info('Nothing to be done to apply upgrade stop to Omnibus', version: version.to_minor, last_required_stop: stop) + return + end + + Retriable.with_context(:api) do + client.create_commit( + project_path, + target_branch, + "Update upgrade stop to #{stop}\n\n[ci skip]", + actions + ) + end + rescue StandardError + logger.fatal('Something with the Omnibus upgrade stop, please disable the maintain_upgrade_stops feature flag, and retry the job. Please notify Distribution about this error.') + + raise end end -- GitLab From 05aa1fee5bf95cd5faf66774d221b278b8888f8e Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 24 Apr 2024 10:54:16 +0200 Subject: [PATCH 27/30] Push Omnibus upgrade stop to default branch * Push the Omnibus upgrade stop to the default branch instead of the stable branch. * This gives Distribution time to validate the updated upgrade stop. * This reduces the risk of a delayed release, in case of a problem with the upgrade stop. The feature flag can be disabled, and the release can proceed as planned. * Check for stops and patch and rc releases (and push them to the default branch if detected). This way the upgrade stop does not have to be decided one milestone in advance. --- .../public_release/omnibus_gitlab_release.rb | 9 ++------- lib/release_tools/public_release/upgrade_stop.rb | 2 +- .../public_release/omnibus_gitlab_release_spec.rb | 14 +------------- .../public_release/upgrade_stop_spec.rb | 14 +++++++------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 2e2eb57cb7..9e5e2346a7 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -149,11 +149,6 @@ module ReleaseTools def update_last_upgrade_stop return if ReleaseTools::Feature.disabled?(:maintain_upgrade_stops) - if version.patch? || version.rc? - logger.info('Patch release or release candidate detected, skipping the Omnibus upgrade stop', version: version) - return - end - begin stop = UpgradeStop.new(version).last_required_stop logger.info('Last required stop for version detected', version: version.to_minor, last_required_stop: stop) @@ -171,7 +166,7 @@ module ReleaseTools Retriable.with_context(:api) do client.create_commit( project_path, - target_branch, + project.default_branch, "Update upgrade stop to #{stop}\n\n[ci skip]", actions ) @@ -184,7 +179,7 @@ module ReleaseTools end def change_upgrade_stop_action!(filename, regexp, replacement) - content = read_file(filename) + content = read_file(filename, branch: project.default_branch) raise "The regexp '#{regexp}' does not match in #{filename}" unless regexp.match?(content) new_content = content.sub(regexp, replacement) diff --git a/lib/release_tools/public_release/upgrade_stop.rb b/lib/release_tools/public_release/upgrade_stop.rb index 96b85c574b..50b28eddf9 100644 --- a/lib/release_tools/public_release/upgrade_stop.rb +++ b/lib/release_tools/public_release/upgrade_stop.rb @@ -14,7 +14,7 @@ module ReleaseTools def last_required_stop last_stop = upgrade_path_hash .map { |stop| Version.new("#{stop['major']}.#{stop['minor']}") } - .select { |stop| stop < @version } + .select { |stop| stop <= @version } .max "#{last_stop.major}.#{last_stop.minor}" if last_stop diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 33a8ec4c62..96907e877a 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -474,7 +474,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect(release.client).to receive(:create_commit).with( release.project_path, - '42-5-stable', + 'master', an_instance_of(String), [ { action: 'update', file_path: pre_install_path, content: pre_install_script(expected_upgrade_stop) }, @@ -517,18 +517,6 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do release.update_last_upgrade_stop end end - - context 'on a patch release' do - let(:version) { ReleaseTools::OmnibusGitlabVersion.new('42.5.1.ee') } - - include_examples 'upgrade stop is not updated' - end - - context 'on a release candicate' do - let(:version) { ReleaseTools::OmnibusGitlabVersion.new('42.5.0-rc1') } - - include_examples 'upgrade stop is not updated' - end end end end diff --git a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb index 4491831f00..aa68caccac 100644 --- a/spec/lib/release_tools/public_release/upgrade_stop_spec.rb +++ b/spec/lib/release_tools/public_release/upgrade_stop_spec.rb @@ -26,19 +26,19 @@ describe ReleaseTools::PublicRelease::UpgradeStop do where(:current_version, :expected_stop) do "29.0.0" | nil - "30.0.0" | nil - "30.0.1" | nil + "29.9.9" | nil + "30.0.0" | "30.0" + "30.0.1" | "30.0" "31.0.0" | "30.0" "39.9.9" | "30.0" - "40.0.0" | "30.0" - "40.0.1" | "30.0" + "40.0.0" | "40.0" + "40.0.1" | "40.0" "40.1.0" | "40.0" "40.8.0" | "40.0" "40.8.1" | "40.0" - "40.10.0" | "40.9" - "40.11.0" | "40.10" + "40.10.0" | "40.10" + "40.11.0" | "40.11" "40.12.0" | "40.11" - "40.11.0" | "40.10" end with_them do -- GitLab From 7db6f9f065b5800ac7f46e610a0705bed2b33a2b Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Wed, 24 Apr 2024 12:23:42 +0200 Subject: [PATCH 28/30] Fix specs --- .../public_release/omnibus_gitlab_release_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb index 96907e877a..0faa307f66 100644 --- a/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb +++ b/spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb @@ -465,11 +465,11 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect_new_upgrade_stop allow(release).to receive(:read_file) - .with(pre_install_path) + .with(pre_install_path, branch: 'master') .and_return(pre_install_script(current_upgrade_stop)) allow(release).to receive(:read_file) - .with(upgrade_check_path) + .with(upgrade_check_path, branch: 'master') .and_return(upgrade_check_script(current_upgrade_stop)) expect(release.client).to receive(:create_commit).with( @@ -490,7 +490,7 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect_new_upgrade_stop allow(release).to receive(:read_file) - .with(pre_install_path) + .with(pre_install_path, branch: 'master') .and_return("foobar") expect { release.update_last_upgrade_stop }.to raise_error(/does not match/) @@ -505,11 +505,11 @@ describe ReleaseTools::PublicRelease::OmnibusGitlabRelease do expect_new_upgrade_stop allow(release).to receive(:read_file) - .with(pre_install_path) + .with(pre_install_path, branch: 'master') .and_return(pre_install_script(current_upgrade_stop)) allow(release).to receive(:read_file) - .with(upgrade_check_path) + .with(upgrade_check_path, branch: 'master') .and_return(upgrade_check_script(current_upgrade_stop)) expect(release.client).not_to receive(:create_commit) -- GitLab From 846453b53eafcd550e1fe3695d9c7b922f5fe864 Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 2 May 2024 11:54:27 +0000 Subject: [PATCH 29/30] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Achilleas Pipinellis --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index 9e5e2346a7..c7ffc6f885 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -172,7 +172,7 @@ module ReleaseTools ) end rescue StandardError - logger.fatal('Something with the Omnibus upgrade stop, please disable the maintain_upgrade_stops feature flag, and retry the job. Please notify Distribution about this error.') + logger.fatal('Something went wrong with the Omnibus upgrade stop. Disable the 'maintain_upgrade_stops' feature flag, and retry the job. Please notify Distribution about this error.') raise end -- GitLab From c6e357e39d93001636e6e3a5c91fdbe752d536ba Mon Sep 17 00:00:00 2001 From: Clemens Beck Date: Thu, 2 May 2024 13:58:53 +0200 Subject: [PATCH 30/30] Fix syntax error --- lib/release_tools/public_release/omnibus_gitlab_release.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/release_tools/public_release/omnibus_gitlab_release.rb b/lib/release_tools/public_release/omnibus_gitlab_release.rb index c7ffc6f885..6341b9eb17 100644 --- a/lib/release_tools/public_release/omnibus_gitlab_release.rb +++ b/lib/release_tools/public_release/omnibus_gitlab_release.rb @@ -172,7 +172,7 @@ module ReleaseTools ) end rescue StandardError - logger.fatal('Something went wrong with the Omnibus upgrade stop. Disable the 'maintain_upgrade_stops' feature flag, and retry the job. Please notify Distribution about this error.') + logger.fatal('Something went wrong with the Omnibus upgrade stop. Disable the \'maintain_upgrade_stops\' feature flag, and retry the job. Please notify Distribution about this error.') raise end -- GitLab