From 233b28cc10be5283128efe43dc023b5d712d26da Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 12 Mar 2024 15:13:03 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- app/models/ci/build.rb | 19 +++---------------- app/models/ci/build_trace_metadata.rb | 5 +---- app/models/ci/job_artifact.rb | 11 +---------- app/services/ci/unlock_pipeline_service.rb | 16 ++++------------ ...artition_id_filter_on_ci_job_artifacts.yml | 9 --------- lib/tasks/grape.rake | 2 -- locale/gitlab.pot | 6 ++++++ spec/lib/gitlab/ci/trace/archive_spec.rb | 1 - .../ci/unlock_pipeline_service_spec.rb | 4 +--- 9 files changed, 16 insertions(+), 57 deletions(-) delete mode 100644 config/feature_flags/gitlab_com_derisk/use_partition_id_filter_on_ci_job_artifacts.yml diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 3fd1cf5aa9f..7bda535c72d 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -61,16 +61,7 @@ module Ci # before we delete builds. By doing this, the relation should be empty and not fire any # DELETE queries when the Ci::Build is destroyed. The next step is to remove `dependent: :destroy`. # Details: https://gitlab.com/gitlab-org/gitlab/-/issues/24644#note_689472685 - # rubocop:disable Cop/ActiveRecordDependent -- See above - has_many :job_artifacts, - ->(build) { in_partition(build) }, - class_name: 'Ci::JobArtifact', - foreign_key: :job_id, - partition_foreign_key: :partition_id, - dependent: :destroy, - inverse_of: :job - # rubocop:enable Cop/ActiveRecordDependent - + has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :job_id, dependent: :destroy, inverse_of: :job # rubocop:disable Cop/ActiveRecordDependent has_many :job_variables, class_name: 'Ci::JobVariable', foreign_key: :job_id, inverse_of: :job has_many :job_annotations, ->(build) { in_partition(build) }, @@ -82,12 +73,8 @@ module Ci has_many :pages_deployments, foreign_key: :ci_build_id, inverse_of: :ci_build - Ci::JobArtifact.file_types.each_key do |key| - has_one :"job_artifacts_#{key}", ->(build) { in_partition(build).with_file_types([key]) }, - class_name: 'Ci::JobArtifact', - foreign_key: :job_id, - partition_foreign_key: :partition_id, - inverse_of: :job + Ci::JobArtifact.file_types.each do |key, value| + has_one :"job_artifacts_#{key}", -> { where(file_type: value) }, class_name: 'Ci::JobArtifact', foreign_key: :job_id, inverse_of: :job end has_one :runner_manager_build, diff --git a/app/models/ci/build_trace_metadata.rb b/app/models/ci/build_trace_metadata.rb index dd5bf13746f..ac0d7ce4e76 100644 --- a/app/models/ci/build_trace_metadata.rb +++ b/app/models/ci/build_trace_metadata.rb @@ -13,10 +13,7 @@ module Ci class_name: 'Ci::Build', partition_foreign_key: :partition_id, inverse_of: :trace_metadata - belongs_to :trace_artifact, # rubocop:disable Rails/InverseOf -- No clear relation to be used - ->(metadata) { in_partition(metadata) }, - class_name: 'Ci::JobArtifact', - partition_foreign_key: :partition_id + belongs_to :trace_artifact, class_name: 'Ci::JobArtifact' partitionable scope: :build diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 620b1b34f24..5a08924fc47 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -24,12 +24,7 @@ module Ci PLAN_LIMIT_PREFIX = 'ci_max_artifact_size_' belongs_to :project - belongs_to :job, - ->(artifact) { in_partition(artifact) }, - class_name: "Ci::Build", - foreign_key: :job_id, - partition_foreign_key: :partition_id, - inverse_of: :job_artifacts + belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id, inverse_of: :job_artifacts mount_file_store_uploader JobArtifactUploader, skip_store_file: true @@ -159,10 +154,6 @@ module Ci service.update_statistics end - def self.use_partition_id_filter? - ::Feature.enabled?(:use_partition_id_filter_on_ci_job_artifacts, Feature.current_request) - end - def local_store? [nil, ::JobArtifactUploader::Store::LOCAL].include?(self.file_store) end diff --git a/app/services/ci/unlock_pipeline_service.rb b/app/services/ci/unlock_pipeline_service.rb index e0e4004f4b2..bd42871ffbe 100644 --- a/app/services/ci/unlock_pipeline_service.rb +++ b/app/services/ci/unlock_pipeline_service.rb @@ -86,12 +86,10 @@ module Ci builds_relation.each_batch(of: BATCH_SIZE) do |builds| # rubocop: disable CodeReuse/ActiveRecord - Ci::JobArtifact.where(job_id: builds.pluck(:id), partition_id: partition_id) - .each_batch(of: BATCH_SIZE) do |job_artifacts| - unlocked_count = Ci::JobArtifact.where( - id: job_artifacts.pluck(:id), - partition_id: partition_id - ).update_all(locked: :unlocked) + Ci::JobArtifact.where(job_id: builds.pluck(:id)).each_batch(of: BATCH_SIZE) do |job_artifacts| + unlocked_count = Ci::JobArtifact + .where(id: job_artifacts.pluck(:id)) + .update_all(locked: :unlocked) @unlocked_job_artifacts_count ||= 0 @unlocked_job_artifacts_count += unlocked_count @@ -112,12 +110,6 @@ module Ci end end - # All the partitionable entities connected to a pipeline - # belong to the same partition where the pipeline is. - def partition_id - pipeline.partition_id - end - def unlock_pipeline_artifacts @unlocked_pipeline_artifacts_count = pipeline.pipeline_artifacts.update_all(locked: :unlocked) end diff --git a/config/feature_flags/gitlab_com_derisk/use_partition_id_filter_on_ci_job_artifacts.yml b/config/feature_flags/gitlab_com_derisk/use_partition_id_filter_on_ci_job_artifacts.yml deleted file mode 100644 index e22e7d1b55c..00000000000 --- a/config/feature_flags/gitlab_com_derisk/use_partition_id_filter_on_ci_job_artifacts.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: use_partition_id_filter_on_ci_job_artifacts -feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/430294 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145522 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/444191 -milestone: '16.10' -group: group::pipeline execution -type: gitlab_com_derisk -default_enabled: false diff --git a/lib/tasks/grape.rake b/lib/tasks/grape.rake index 9f0499ae86d..c72403a375a 100644 --- a/lib/tasks/grape.rake +++ b/lib/tasks/grape.rake @@ -3,8 +3,6 @@ namespace :grape do desc 'Print compiled grape routes' task routes: :environment do - # Getting the source of the endpoints - # https://forum.gitlab.com/t/corresponding-ruby-file-for-route-api-v4-jobs-request/16663 API::API.routes.each do |route| puts "#{route.options[:method]} #{route.path} - #{route_description(route.options)}" end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index a886a503572..0d0dbc5899c 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1938,6 +1938,9 @@ msgstr "" msgid "AIAgents|AI Agents" msgstr "" +msgid "AIAgents|Agent Settings" +msgstr "" + msgid "AIAgents|An error has occurred when saving the agent." msgstr "" @@ -1950,6 +1953,9 @@ msgstr "" msgid "AIAgents|The requested agent was not found." msgstr "" +msgid "AIAgents|Update the name and prompt for this agent." +msgstr "" + msgid "AIAgent|AI Agent: %{agentId}" msgstr "" diff --git a/spec/lib/gitlab/ci/trace/archive_spec.rb b/spec/lib/gitlab/ci/trace/archive_spec.rb index f7a747092a3..cce6477b91e 100644 --- a/spec/lib/gitlab/ci/trace/archive_spec.rb +++ b/spec/lib/gitlab/ci/trace/archive_spec.rb @@ -137,7 +137,6 @@ RSpec.describe Gitlab::Ci::Trace::Archive, feature_category: :scalability do allow_next_instance_of(Ci::JobArtifact) do |artifact| artifact.job_id = job.id - artifact.partition_id = job.partition_id expect(artifact) .to receive(:store_file!) diff --git a/spec/services/ci/unlock_pipeline_service_spec.rb b/spec/services/ci/unlock_pipeline_service_spec.rb index 80d98c8c394..16537ce5eaa 100644 --- a/spec/services/ci/unlock_pipeline_service_spec.rb +++ b/spec/services/ci/unlock_pipeline_service_spec.rb @@ -115,9 +115,7 @@ RSpec.describe Ci::UnlockPipelineService, :unlock_pipelines, :clean_gitlab_redis before do mock_relation = instance_double('Ci::JobArtifact::ActiveRecord_Relation') allow(Ci::JobArtifact).to receive(:where).and_call_original - allow(Ci::JobArtifact).to receive(:where) - .with(id: [last_artifact.id], partition_id: last_artifact.partition_id) - .and_return(mock_relation) + allow(Ci::JobArtifact).to receive(:where).with(id: [last_artifact.id]).and_return(mock_relation) allow(mock_relation).to receive(:update_all).and_raise('An error') end