diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-13 06:09:20 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-13 06:09:20 +0000 |
commit | 00d1f41541a21e13e3c6bd94d897dc5e4da8278a (patch) | |
tree | b5bf678b7f004c60e152414f52e8d279346e7a70 | |
parent | 6b15723e0656c73c0c3971e71629d73d62c49974 (diff) | |
download | gitlab-ce-00d1f41541a21e13e3c6bd94d897dc5e4da8278a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | app/assets/javascripts/vue_shared/components/blob_viewers/rich_viewer.vue | 2 | ||||
-rw-r--r-- | app/models/ci/runner.rb | 4 | ||||
-rw-r--r-- | app/models/ci/runner_machine.rb | 5 | ||||
-rw-r--r-- | db/migrate/20230208103640_rename_runner_machine_xid.rb | 13 | ||||
-rw-r--r-- | db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb | 13 | ||||
-rw-r--r-- | db/schema_migrations/20230208103640 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20230208110638 | 1 | ||||
-rw-r--r-- | db/structure.sql | 27 | ||||
-rw-r--r-- | doc/architecture/blueprints/runner_tokens/index.md | 4 | ||||
-rw-r--r-- | lib/api/ci/helpers/runner.rb | 2 | ||||
-rw-r--r-- | lib/api/entities/wiki_page.rb | 2 | ||||
-rw-r--r-- | spec/factories/ci/runner_machines.rb | 2 | ||||
-rw-r--r-- | spec/lib/api/ci/helpers/runner_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/approval_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/runner_machine_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/ci/runner/jobs_request_post_spec.rb | 8 |
16 files changed, 65 insertions, 31 deletions
diff --git a/app/assets/javascripts/vue_shared/components/blob_viewers/rich_viewer.vue b/app/assets/javascripts/vue_shared/components/blob_viewers/rich_viewer.vue index 49181bb847d..3a3929fba9b 100644 --- a/app/assets/javascripts/vue_shared/components/blob_viewers/rich_viewer.vue +++ b/app/assets/javascripts/vue_shared/components/blob_viewers/rich_viewer.vue @@ -16,7 +16,7 @@ export default { handleBlobRichViewer(this.$refs.content, this.type); }, safeHtmlConfig: { - ADD_TAGS: ['copy-code'], + ADD_TAGS: ['gl-emoji', 'copy-code'], }, }; </script> diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index eea8915b690..a0802ee6330 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -502,8 +502,8 @@ module Ci token.start_with?(CREATED_RUNNER_TOKEN_PREFIX) end - def ensure_machine(machine_xid:, &blk) - RunnerMachine.safe_find_or_create_by!(runner_id: id, machine_xid: machine_xid.to_s, &blk) # rubocop: disable Performance/ActiveRecordSubtransactionMethods + def ensure_machine(system_xid:, &blk) + RunnerMachine.safe_find_or_create_by!(runner_id: id, system_xid: system_xid.to_s, &blk) # rubocop: disable Performance/ActiveRecordSubtransactionMethods end private diff --git a/app/models/ci/runner_machine.rb b/app/models/ci/runner_machine.rb index d41d0c11e33..7048a9c027a 100644 --- a/app/models/ci/runner_machine.rb +++ b/app/models/ci/runner_machine.rb @@ -4,6 +4,9 @@ module Ci class RunnerMachine < Ci::ApplicationRecord include FromUnion include Ci::HasRunnerExecutor + include IgnorableColumns + + ignore_column :machine_xid, remove_with: '15.10', remove_after: '2022-03-22' belongs_to :runner @@ -13,7 +16,7 @@ module Ci class_name: 'Ci::RunnerVersion' validates :runner, presence: true - validates :machine_xid, presence: true, length: { maximum: 64 } + validates :system_xid, presence: true, length: { maximum: 64 } validates :version, length: { maximum: 2048 } validates :revision, length: { maximum: 255 } validates :platform, length: { maximum: 255 } diff --git a/db/migrate/20230208103640_rename_runner_machine_xid.rb b/db/migrate/20230208103640_rename_runner_machine_xid.rb new file mode 100644 index 00000000000..c9c9ffd324f --- /dev/null +++ b/db/migrate/20230208103640_rename_runner_machine_xid.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RenameRunnerMachineXid < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + rename_column_concurrently :ci_runner_machines, :machine_xid, :system_xid + end + + def down + undo_rename_column_concurrently :ci_runner_machines, :machine_xid, :system_xid + end +end diff --git a/db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb b/db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb new file mode 100644 index 00000000000..b596d7773ae --- /dev/null +++ b/db/post_migrate/20230208110638_cleanup_ci_runner_machines_machine_xid_rename.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class CleanupCiRunnerMachinesMachineXidRename < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + cleanup_concurrent_column_rename :ci_runner_machines, :machine_xid, :system_xid + end + + def down + undo_cleanup_concurrent_column_rename :ci_runner_machines, :machine_xid, :system_xid + end +end diff --git a/db/schema_migrations/20230208103640 b/db/schema_migrations/20230208103640 new file mode 100644 index 00000000000..7a9e6a603cb --- /dev/null +++ b/db/schema_migrations/20230208103640 @@ -0,0 +1 @@ +7f000addc9083ff438abccdbd607fc702d1999a7a182d375d5b7355f0b03304b
\ No newline at end of file diff --git a/db/schema_migrations/20230208110638 b/db/schema_migrations/20230208110638 new file mode 100644 index 00000000000..3aa5c616646 --- /dev/null +++ b/db/schema_migrations/20230208110638 @@ -0,0 +1 @@ +fac390d1508329864c7e859e1c302e00868679b5438c2f5a31dfdaea7ba73eab
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 10c76e979bb..9f4100a0d20 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -261,11 +261,11 @@ BEGIN END; $$; -CREATE FUNCTION trigger_775287b6d67a() RETURNS trigger +CREATE FUNCTION trigger_482bac5ec48a() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - NEW."diff_note_id_convert_to_bigint" := NEW."diff_note_id"; + NEW."note_id_convert_to_bigint" := NEW."note_id"; RETURN NEW; END; $$; @@ -279,25 +279,25 @@ BEGIN END; $$; -CREATE FUNCTION trigger_7f4fcd5aa322() RETURNS trigger +CREATE FUNCTION trigger_775287b6d67a() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - NEW."id_convert_to_bigint" := NEW."id"; + NEW."diff_note_id_convert_to_bigint" := NEW."diff_note_id"; RETURN NEW; END; $$; -CREATE FUNCTION trigger_bfc6e47be8cc() RETURNS trigger +CREATE FUNCTION trigger_7f4fcd5aa322() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - NEW."note_id_convert_to_bigint" := NEW."note_id"; + NEW."id_convert_to_bigint" := NEW."id"; RETURN NEW; END; $$; -CREATE FUNCTION trigger_c2051020aa8b() RETURNS trigger +CREATE FUNCTION trigger_bfc6e47be8cc() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN @@ -306,7 +306,7 @@ BEGIN END; $$; -CREATE FUNCTION trigger_482bac5ec48a() RETURNS trigger +CREATE FUNCTION trigger_c2051020aa8b() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN @@ -13545,7 +13545,6 @@ CREATE TABLE ci_runner_machines ( id bigint NOT NULL, runner_id bigint NOT NULL, executor_type smallint, - machine_xid text NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, contacted_at timestamp with time zone, @@ -13555,11 +13554,13 @@ CREATE TABLE ci_runner_machines ( architecture text, ip_address text, config jsonb DEFAULT '{}'::jsonb NOT NULL, + system_xid text, CONSTRAINT check_1537c1f66f CHECK ((char_length(platform) <= 255)), + CONSTRAINT check_5253913ae9 CHECK ((char_length(system_xid) <= 64)), CONSTRAINT check_6f45a91da7 CHECK ((char_length(version) <= 2048)), - CONSTRAINT check_84ed5d8703 CHECK ((char_length(machine_xid) <= 64)), CONSTRAINT check_9b521b3105 CHECK ((char_length(architecture) <= 255)), CONSTRAINT check_afb8efc1a2 CHECK ((char_length(revision) <= 255)), + CONSTRAINT check_b714f452d5 CHECK ((system_xid IS NOT NULL)), CONSTRAINT check_f214590856 CHECK ((char_length(ip_address) <= 1024)) ); @@ -29377,7 +29378,7 @@ CREATE INDEX index_ci_runner_machines_on_contacted_at_desc_and_id_desc ON ci_run CREATE INDEX index_ci_runner_machines_on_created_at_and_id_desc ON ci_runner_machines USING btree (created_at, id DESC); -CREATE UNIQUE INDEX index_ci_runner_machines_on_runner_id_and_machine_xid ON ci_runner_machines USING btree (runner_id, machine_xid); +CREATE UNIQUE INDEX index_ci_runner_machines_on_runner_id_and_system_xid ON ci_runner_machines USING btree (runner_id, system_xid); CREATE INDEX index_ci_runner_machines_on_version ON ci_runner_machines USING btree (version); @@ -33593,6 +33594,8 @@ CREATE TRIGGER trigger_3207b8d0d6f3 BEFORE INSERT OR UPDATE ON ci_build_needs FO CREATE TRIGGER trigger_3dc62927cae8 BEFORE INSERT OR UPDATE ON design_user_mentions FOR EACH ROW EXECUTE FUNCTION trigger_3dc62927cae8(); +CREATE TRIGGER trigger_482bac5ec48a BEFORE INSERT OR UPDATE ON system_note_metadata FOR EACH ROW EXECUTE FUNCTION trigger_482bac5ec48a(); + CREATE TRIGGER trigger_775287b6d67a BEFORE INSERT OR UPDATE ON note_diff_files FOR EACH ROW EXECUTE FUNCTION trigger_775287b6d67a(); CREATE TRIGGER trigger_428d92773fe7 BEFORE INSERT OR UPDATE ON timelogs FOR EACH ROW EXECUTE FUNCTION trigger_428d92773fe7(); @@ -33603,8 +33606,6 @@ CREATE TRIGGER trigger_bfc6e47be8cc BEFORE INSERT OR UPDATE ON snippet_user_ment CREATE TRIGGER trigger_c2051020aa8b BEFORE INSERT OR UPDATE ON issue_user_mentions FOR EACH ROW EXECUTE FUNCTION trigger_c2051020aa8b(); -CREATE TRIGGER trigger_482bac5ec48a BEFORE INSERT OR UPDATE ON system_note_metadata FOR EACH ROW EXECUTE FUNCTION trigger_482bac5ec48a(); - CREATE TRIGGER trigger_c5a5f48f12b0 BEFORE INSERT OR UPDATE ON epic_user_mentions FOR EACH ROW EXECUTE FUNCTION trigger_c5a5f48f12b0(); CREATE TRIGGER trigger_c7107f30d69d BEFORE INSERT OR UPDATE ON merge_request_metrics FOR EACH ROW EXECUTE FUNCTION trigger_c7107f30d69d(); diff --git a/doc/architecture/blueprints/runner_tokens/index.md b/doc/architecture/blueprints/runner_tokens/index.md index f676ac5dc81..a8cc4aad648 100644 --- a/doc/architecture/blueprints/runner_tokens/index.md +++ b/doc/architecture/blueprints/runner_tokens/index.md @@ -167,7 +167,7 @@ CREATE TABLE ci_builds_metadata ( CREATE TABLE ci_runner_machines ( id bigint NOT NULL, - machine_xid character varying UNIQUE NOT NULL, + system_xid character varying UNIQUE NOT NULL, contacted_at timestamp without time zone, version character varying, revision character varying, @@ -242,7 +242,7 @@ future after the legacy registration system is removed, and runners have been up versions. Job pings from such legacy runners results in a `ci_runner_machines` record containing a -`<legacy>` `machine_xid` field value. +`<legacy>` `system_xid` field value. Not using the unique system ID means that all connected runners with the same token are notified, instead of just the runner matching the exact system identifier. While not ideal, this is diff --git a/lib/api/ci/helpers/runner.rb b/lib/api/ci/helpers/runner.rb index fddbfa735e3..cbfa2b58672 100644 --- a/lib/api/ci/helpers/runner.rb +++ b/lib/api/ci/helpers/runner.rb @@ -55,7 +55,7 @@ module API return unless params[:system_id] strong_memoize(:current_runner_machine) do - current_runner.ensure_machine(machine_xid: params[:system_id]) { |m| m.contacted_at = Time.current } + current_runner.ensure_machine(system_xid: params[:system_id]) { |m| m.contacted_at = Time.current } end end diff --git a/lib/api/entities/wiki_page.rb b/lib/api/entities/wiki_page.rb index 07ef4a4a156..9d2a031cee8 100644 --- a/lib/api/entities/wiki_page.rb +++ b/lib/api/entities/wiki_page.rb @@ -25,3 +25,5 @@ module API end end end + +API::Entities::WikiPage.prepend_mod diff --git a/spec/factories/ci/runner_machines.rb b/spec/factories/ci/runner_machines.rb index c382ebdcb26..9d601caa634 100644 --- a/spec/factories/ci/runner_machines.rb +++ b/spec/factories/ci/runner_machines.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :ci_runner_machine, class: 'Ci::RunnerMachine' do runner factory: :ci_runner - machine_xid { "r_#{SecureRandom.hex.slice(0, 10)}" } + system_xid { "r_#{SecureRandom.hex.slice(0, 10)}" } trait :stale do created_at { 1.year.ago } diff --git a/spec/lib/api/ci/helpers/runner_spec.rb b/spec/lib/api/ci/helpers/runner_spec.rb index b5046bb9983..7f711ba1ca0 100644 --- a/spec/lib/api/ci/helpers/runner_spec.rb +++ b/spec/lib/api/ci/helpers/runner_spec.rb @@ -69,7 +69,7 @@ RSpec.describe API::Ci::Helpers::Runner do describe '#current_runner_machine', :freeze_time, feature_category: :runner_fleet do let(:runner) { create(:ci_runner, token: 'foo') } - let(:runner_machine) { create(:ci_runner_machine, runner: runner, machine_xid: 'bar', contacted_at: 1.hour.ago) } + let(:runner_machine) { create(:ci_runner_machine, runner: runner, system_xid: 'bar', contacted_at: 1.hour.ago) } subject(:current_runner_machine) { helper.current_runner_machine } @@ -86,7 +86,7 @@ RSpec.describe API::Ci::Helpers::Runner do context 'when runner machine already exists' do before do - allow(helper).to receive(:params).and_return(token: runner.token, system_id: runner_machine.machine_xid) + allow(helper).to receive(:params).and_return(token: runner.token, system_id: runner_machine.system_xid) end it { is_expected.to eq(runner_machine) } @@ -102,7 +102,7 @@ RSpec.describe API::Ci::Helpers::Runner do expect { current_runner_machine }.to change { Ci::RunnerMachine.count }.by(1) expect(current_runner_machine).not_to be_nil - expect(current_runner_machine.machine_xid).to eq('new_system_id') + expect(current_runner_machine.system_xid).to eq('new_system_id') expect(current_runner_machine.contacted_at).to eq(Time.current) expect(current_runner_machine.runner).to eq(runner) end diff --git a/spec/models/approval_spec.rb b/spec/models/approval_spec.rb index e2c0d5faa07..3d382c1712a 100644 --- a/spec/models/approval_spec.rb +++ b/spec/models/approval_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Approval do +RSpec.describe Approval, feature_category: :code_review_workflow do context 'presence validation' do it { is_expected.to validate_presence_of(:merge_request_id) } it { is_expected.to validate_presence_of(:user_id) } diff --git a/spec/models/ci/runner_machine_spec.rb b/spec/models/ci/runner_machine_spec.rb index 530b3ff2e8d..79d383ad182 100644 --- a/spec/models/ci/runner_machine_spec.rb +++ b/spec/models/ci/runner_machine_spec.rb @@ -12,8 +12,8 @@ RSpec.describe Ci::RunnerMachine, feature_category: :runner_fleet, type: :model describe 'validation' do it { is_expected.to validate_presence_of(:runner) } - it { is_expected.to validate_presence_of(:machine_xid) } - it { is_expected.to validate_length_of(:machine_xid).is_at_most(64) } + it { is_expected.to validate_presence_of(:system_xid) } + it { is_expected.to validate_length_of(:system_xid).is_at_most(64) } it { is_expected.to validate_length_of(:version).is_at_most(2048) } it { is_expected.to validate_length_of(:revision).is_at_most(255) } it { is_expected.to validate_length_of(:platform).is_at_most(255) } diff --git a/spec/requests/api/ci/runner/jobs_request_post_spec.rb b/spec/requests/api/ci/runner/jobs_request_post_spec.rb index c11381fe448..618adeb7db0 100644 --- a/spec/requests/api/ci/runner/jobs_request_post_spec.rb +++ b/spec/requests/api/ci/runner/jobs_request_post_spec.rb @@ -122,22 +122,22 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state, feature_catego context 'when system_id parameter is specified' do subject(:request) { request_job(**args) } - context 'when ci_runner_machines with same machine_xid does not exist' do + context 'when ci_runner_machines with same system_xid does not exist' do let(:args) { { system_id: 's_some_system_id' } } it 'creates respective ci_runner_machines record', :freeze_time do expect { request }.to change { runner.runner_machines.reload.count }.from(0).to(1) machine = runner.runner_machines.last - expect(machine.machine_xid).to eq args[:system_id] + expect(machine.system_xid).to eq args[:system_id] expect(machine.runner).to eq runner expect(machine.contacted_at).to eq Time.current end end - context 'when ci_runner_machines with same machine_xid already exists' do + context 'when ci_runner_machines with same system_xid already exists' do let(:args) { { system_id: 's_existing_system_id' } } - let!(:runner_machine) { create(:ci_runner_machine, runner: runner, machine_xid: args[:system_id]) } + let!(:runner_machine) { create(:ci_runner_machine, runner: runner, system_xid: args[:system_id]) } it 'does not create new ci_runner_machines record' do expect { request }.not_to change { Ci::RunnerMachine.count } |