diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index ca7f539d386c0330eefc9419f8daa53d4c7a7bc7..ad84d2e9b8c383efffc8f5d82ac4fc5d02f37a01 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -14,19 +14,21 @@ class JobArtifact < Ci::ApplicationRecord include EachBatch include Gitlab::Utils::StrongMemoize - ROUTING_FEATURE_FLAG = :ci_partitioning_use_ci_job_artifacts_routing_table + PLAN_LIMIT_PREFIX = 'ci_max_artifact_size_' + self.table_name = :p_ci_job_artifacts self.primary_key = :id self.sequence_name = :ci_job_artifacts_id_seq - enum accessibility: { public: 0, private: 1, none: 2 }, _suffix: true + partitionable scope: :job, partitioned: true - PLAN_LIMIT_PREFIX = 'ci_max_artifact_size_' + enum accessibility: { public: 0, private: 1, none: 2 }, _suffix: true belongs_to :project belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id, inverse_of: :job_artifacts mount_file_store_uploader JobArtifactUploader, skip_store_file: true + update_project_statistics project_statistics_name: :build_artifacts_size before_save :set_size, if: :file_changed? after_save :store_file_in_transaction!, unless: :store_after_commit? @@ -41,12 +43,6 @@ class JobArtifact < Ci::ApplicationRecord validates :file_format, presence: true, unless: :trace?, on: :create validate :validate_file_format!, unless: :trace?, on: :create - update_project_statistics project_statistics_name: :build_artifacts_size - partitionable scope: :job, through: { - table: :p_ci_job_artifacts, - flag: ROUTING_FEATURE_FLAG - } - scope :not_expired, -> { where('expire_at IS NULL OR expire_at > ?', Time.current) } scope :for_sha, ->(sha, project_id) { joins(job: :pipeline).where(ci_pipelines: { sha: sha, project_id: project_id }) } scope :for_job_ids, ->(job_ids) { where(job_id: job_ids) } diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 79199b3e5b0022c083fd62bf1d41ab9464bc0067..2eeb832bbc3fa86841e28efec84ce53185510a7d 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -8,15 +8,11 @@ class Stage < Ci::ApplicationRecord include Gitlab::OptimisticLocking include Presentable - ROUTING_FEATURE_FLAG = :ci_partitioning_use_ci_stages_routing_table - + self.table_name = :p_ci_stages self.primary_key = :id self.sequence_name = :ci_job_stages_id_seq - partitionable scope: :pipeline, through: { - table: :p_ci_stages, - flag: ROUTING_FEATURE_FLAG - } + partitionable scope: :pipeline, partitioned: true enum status: Ci::HasStatus::STATUSES_ENUM diff --git a/config/feature_flags/gitlab_com_derisk/ci_partitioning_use_ci_job_artifacts_routing_table.yml b/config/feature_flags/gitlab_com_derisk/ci_partitioning_use_ci_job_artifacts_routing_table.yml deleted file mode 100644 index e85f84643a3ee41ec548b2181f113fa577f7ebab..0000000000000000000000000000000000000000 --- a/config/feature_flags/gitlab_com_derisk/ci_partitioning_use_ci_job_artifacts_routing_table.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: ci_partitioning_use_ci_job_artifacts_routing_table -feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/440760 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144709 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/441759 -milestone: '16.10' -group: group::pipeline execution -type: gitlab_com_derisk -default_enabled: false diff --git a/config/feature_flags/gitlab_com_derisk/ci_partitioning_use_ci_stages_routing_table.yml b/config/feature_flags/gitlab_com_derisk/ci_partitioning_use_ci_stages_routing_table.yml deleted file mode 100644 index 5ff4d3fab2d2d21fd259c9c6facafe2193791b7d..0000000000000000000000000000000000000000 --- a/config/feature_flags/gitlab_com_derisk/ci_partitioning_use_ci_stages_routing_table.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: ci_partitioning_use_ci_stages_routing_table -feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/440759 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145902 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/443421 -milestone: '16.10' -group: group::pipeline execution -type: gitlab_com_derisk -default_enabled: false diff --git a/db/docs/p_ci_job_artifacts.yml b/db/docs/p_ci_job_artifacts.yml index adca9eca071e448d682b05a23907e7a46e4c3799..5bb3dc580c7373097ce5bf99ff57fcd82b1412db 100644 --- a/db/docs/p_ci_job_artifacts.yml +++ b/db/docs/p_ci_job_artifacts.yml @@ -2,7 +2,6 @@ table_name: p_ci_job_artifacts classes: - Ci::JobArtifact -- Ci::JobArtifact::Partitioned feature_categories: - continuous_integration description: Routing table for ci_job_artifacts diff --git a/db/docs/p_ci_stages.yml b/db/docs/p_ci_stages.yml index d398fef5fe5b709263c70a062b3752ebec43294b..a97ea4d94cb06624adb2149c0bc70ae745ffb4e9 100644 --- a/db/docs/p_ci_stages.yml +++ b/db/docs/p_ci_stages.yml @@ -2,7 +2,6 @@ table_name: p_ci_stages classes: - Ci::Stage -- Ci::Stage::Partitioned feature_categories: - continuous_integration description: Routing table for ci_stages diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb index 76269868dcf7c9a5e2b434e62da298146b087326..9087c69f1dfc883912c5fa9659a1a1326a436764 100644 --- a/spec/models/ci/job_artifact_spec.rb +++ b/spec/models/ci/job_artifact_spec.rb @@ -888,26 +888,4 @@ def file_type_limit_failure_message(type, limit_name) it_behaves_like 'returning attributes for object deletion' end end - - describe 'routing table switch' do - context 'with ff disabled' do - before do - stub_feature_flags(ci_partitioning_use_ci_job_artifacts_routing_table: false) - end - - it 'uses the legacy table' do - expect(described_class.table_name).to eq('ci_job_artifacts') - end - end - - context 'with ff enabled' do - before do - stub_feature_flags(ci_partitioning_use_ci_job_artifacts_routing_table: true) - end - - it 'uses the routing table' do - expect(described_class.table_name).to eq('p_ci_job_artifacts') - end - end - end end diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb index 994a83072af7138387a43eed2eee8459c3474d8d..c214d6a88c3d4d2ac7c8173c81dd9b0be8955472 100644 --- a/spec/models/ci/stage_spec.rb +++ b/spec/models/ci/stage_spec.rb @@ -440,26 +440,4 @@ def transitionable?(from, to) end end end - - describe 'routing table switch' do - context 'with ff disabled' do - before do - stub_feature_flags(ci_partitioning_use_ci_stages_routing_table: false) - end - - it 'uses the legacy table' do - expect(described_class.table_name).to eq('ci_stages') - end - end - - context 'with ff enabled' do - before do - stub_feature_flags(ci_partitioning_use_ci_stages_routing_table: true) - end - - it 'uses the routing table' do - expect(described_class.table_name).to eq('p_ci_stages') - end - end - end end