Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
14bdd853a1
commit
51338fbd8a
6 changed files with 81 additions and 15 deletions
|
@ -1172,7 +1172,7 @@ class Project < ApplicationRecord
|
|||
job_type = type.to_s.capitalize
|
||||
|
||||
if job_id
|
||||
Gitlab::AppLogger.info("#{job_type} job scheduled for #{full_path} with job ID #{job_id}.")
|
||||
Gitlab::AppLogger.info("#{job_type} job scheduled for #{full_path} with job ID #{job_id} (primary: #{::Gitlab::Database::LoadBalancing::Session.current.use_primary?}).")
|
||||
else
|
||||
Gitlab::AppLogger.error("#{job_type} job failed to create for #{full_path}.")
|
||||
end
|
||||
|
|
|
@ -20,15 +20,27 @@ module Gitlab
|
|||
return :invalid unless runner_version
|
||||
|
||||
releases = RunnerReleases.instance.releases
|
||||
parsed_runner_version = runner_version.is_a?(::Gitlab::VersionInfo) ? runner_version : ::Gitlab::VersionInfo.parse(runner_version)
|
||||
orig_runner_version = runner_version
|
||||
runner_version = ::Gitlab::VersionInfo.parse(runner_version) unless runner_version.is_a?(::Gitlab::VersionInfo)
|
||||
|
||||
raise ArgumentError, "'#{runner_version}' is not a valid version" unless parsed_runner_version.valid?
|
||||
raise ArgumentError, "'#{orig_runner_version}' is not a valid version" unless runner_version.valid?
|
||||
|
||||
available_releases = releases.reject { |release| release > @gitlab_version }
|
||||
gitlab_minor_version = version_without_patch(@gitlab_version)
|
||||
|
||||
return :recommended if available_releases.any? { |available_release| patch_update?(available_release, parsed_runner_version) }
|
||||
return :recommended if outside_backport_window?(parsed_runner_version, releases)
|
||||
return :available if available_releases.any? { |available_release| available_release > parsed_runner_version }
|
||||
available_releases = releases
|
||||
.reject { |release| release.major > @gitlab_version.major }
|
||||
.reject do |release|
|
||||
release_minor_version = version_without_patch(release)
|
||||
|
||||
# Do not reject a patch update, even if the runner is ahead of the instance version
|
||||
next false if version_without_patch(runner_version) == release_minor_version
|
||||
|
||||
release_minor_version > gitlab_minor_version
|
||||
end
|
||||
|
||||
return :recommended if available_releases.any? { |available_rel| patch_update?(available_rel, runner_version) }
|
||||
return :recommended if outside_backport_window?(runner_version, releases)
|
||||
return :available if available_releases.any? { |available_rel| available_rel > runner_version }
|
||||
|
||||
:not_available
|
||||
end
|
||||
|
|
|
@ -39,18 +39,31 @@ module Gitlab
|
|||
end
|
||||
|
||||
job['wal_locations'] = locations
|
||||
job['wal_location_source'] = wal_location_source
|
||||
end
|
||||
|
||||
def wal_location_source
|
||||
if ::Gitlab::Database::LoadBalancing.primary_only? || uses_primary?
|
||||
::Gitlab::Database::LoadBalancing::ROLE_PRIMARY
|
||||
else
|
||||
::Gitlab::Database::LoadBalancing::ROLE_REPLICA
|
||||
end
|
||||
end
|
||||
|
||||
def wal_location_for(load_balancer)
|
||||
# When only using the primary there's no need for any WAL queries.
|
||||
return if load_balancer.primary_only?
|
||||
|
||||
if ::Gitlab::Database::LoadBalancing::Session.current.use_primary?
|
||||
if uses_primary?
|
||||
load_balancer.primary_write_location
|
||||
else
|
||||
load_balancer.host.database_replica_location
|
||||
end
|
||||
end
|
||||
|
||||
def uses_primary?
|
||||
::Gitlab::Database::LoadBalancing::Session.current.use_primary?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
36
scripts/glfm/run-snapshot-tests.sh
Executable file
36
scripts/glfm/run-snapshot-tests.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# shellcheck disable=SC2059
|
||||
|
||||
set -o errexit # AKA -e - exit immediately on errors (http://mywiki.wooledge.org/BashFAQ/105)
|
||||
|
||||
# https://stackoverflow.com/a/28938235
|
||||
BCyan='\033[1;36m' # Bold Cyan
|
||||
BRed='\033[1;31m' # Bold Red
|
||||
BGreen='\033[1;32m' # Bold Green
|
||||
BBlue='\033[1;34m' # Bold Blue
|
||||
Color_Off='\033[0m' # Text Reset
|
||||
|
||||
function onexit_err() {
|
||||
local exit_status=${1:-$?}
|
||||
printf "\n❌❌❌ ${BRed}GLFM snapshot tests failed!${Color_Off} ❌❌❌\n"
|
||||
exit "${exit_status}"
|
||||
}
|
||||
trap onexit_err ERR
|
||||
set -o errexit
|
||||
|
||||
printf "${BCyan}"
|
||||
printf "\nStarting GLFM snapshot example tests. See https://docs.gitlab.com/ee/development/gitlab_flavored_markdown/specification_guide/#run-snapshot-testssh-script for more details.\n\n"
|
||||
printf "Set 'FOCUSED_MARKDOWN_EXAMPLES=example_name_1[,...]' for focused examples, with example name(s) from https://docs.gitlab.com/ee/development/gitlab_flavored_markdown/specification_guide/#glfm_specificationexample_snapshotsexamples_indexyml.\n"
|
||||
printf "${Color_Off}"
|
||||
|
||||
# This section can be uncommented as soon as this is merged: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89953
|
||||
#printf "\n${BBlue}Running frontend 'yarn jest spec/frontend/content_editor/markdown_snapshot_spec.js'...${Color_Off}\n\n"
|
||||
#yarn jest spec/frontend/content_editor/markdown_snapshot_spec.js
|
||||
#printf "\n${BBlue}'yarn jest spec/frontend/content_editor/markdown_snapshot_spec.js' passed!${Color_Off}\n\n"
|
||||
|
||||
printf "\n${BBlue}Running backend 'bundle exec rspec spec/requests/api/markdown_snapshot_spec.rb'...${Color_Off}\n\n"
|
||||
bundle exec rspec spec/requests/api/markdown_snapshot_spec.rb
|
||||
printf "\n${BBlue}'bundle exec rspec spec/requests/api/markdown_snapshot_spec.rb' passed!${Color_Off}\n\n"
|
||||
|
||||
printf "\n✅✅✅ ${BGreen}All GLFM snapshot example tests passed successfully!${Color_Off} ✅✅✅\n"
|
|
@ -51,21 +51,22 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with Gitlab::VERSION set to 14.0.123' do
|
||||
context 'with Gitlab::VERSION set to 14.0.1' do
|
||||
before do
|
||||
stub_version('14.0.123', 'deadbeef')
|
||||
stub_version('14.0.1', 'deadbeef')
|
||||
|
||||
described_class.instance.reset!
|
||||
end
|
||||
|
||||
context 'with valid params' do
|
||||
where(:runner_version, :expected_result) do
|
||||
'v14.1.0-rc3' | :not_available # not available since the GitLab instance is still on 14.0.x
|
||||
'v14.1.0~beta.1574.gf6ea9389' | :not_available # suffixes are correctly handled
|
||||
'v14.1.0/1.1.0' | :not_available # suffixes are correctly handled
|
||||
'v14.1.0' | :not_available # not available since the GitLab instance is still on 14.0.x
|
||||
'v15.0.0' | :not_available # not available since the GitLab instance is still on 14.x and a major version might be incompatible
|
||||
'v14.1.0-rc3' | :recommended # recommended since even though the GitLab instance is still on 14.0.x, there is a patch release (14.1.1) available which might contain security fixes
|
||||
'v14.1.0~beta.1574.gf6ea9389' | :recommended # suffixes are correctly handled
|
||||
'v14.1.0/1.1.0' | :recommended # suffixes are correctly handled
|
||||
'v14.1.0' | :recommended # recommended since even though the GitLab instance is still on 14.0.x, there is a patch release (14.1.1) available which might contain security fixes
|
||||
'v14.0.1' | :recommended # recommended upgrade since 14.0.2 is available
|
||||
'v14.0.2' | :not_available # not available since 14.0.2 is the latest 14.0.x release available
|
||||
'v14.0.2' | :not_available # not available since 14.0.2 is the latest 14.0.x release available within the instance's major.minor version
|
||||
'v13.10.1' | :available # available upgrade: 14.1.1
|
||||
'v13.10.1~beta.1574.gf6ea9389' | :available # suffixes are correctly handled
|
||||
'v13.10.1/1.1.0' | :available # suffixes are correctly handled
|
||||
|
|
|
@ -57,6 +57,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
|
|||
run_middleware
|
||||
|
||||
expect(job['wal_locations']).to be_nil
|
||||
expect(job['wal_location_source']).to be_nil
|
||||
end
|
||||
|
||||
include_examples 'job data consistency'
|
||||
|
@ -96,6 +97,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
|
|||
run_middleware
|
||||
|
||||
expect(job['wal_locations']).to eq(expected_location)
|
||||
expect(job['wal_location_source']).to eq(:replica)
|
||||
end
|
||||
|
||||
include_examples 'job data consistency'
|
||||
|
@ -120,6 +122,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
|
|||
run_middleware
|
||||
|
||||
expect(job['wal_locations']).to eq(expected_location)
|
||||
expect(job['wal_location_source']).to eq(:primary)
|
||||
end
|
||||
|
||||
include_examples 'job data consistency'
|
||||
|
@ -162,6 +165,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::SidekiqClientMiddleware do
|
|||
run_middleware
|
||||
|
||||
expect(job['wal_locations']).to eq(wal_locations)
|
||||
expect(job['wal_location_source']).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue