diff options
Diffstat (limited to 'app/workers/projects')
4 files changed, 47 insertions, 10 deletions
diff --git a/app/workers/projects/delete_branch_worker.rb b/app/workers/projects/delete_branch_worker.rb index 1949fb67e83..339fa478de9 100644 --- a/app/workers/projects/delete_branch_worker.rb +++ b/app/workers/projects/delete_branch_worker.rb @@ -4,6 +4,9 @@ module Projects class DeleteBranchWorker include ApplicationWorker + # Temporary error when Gitaly cannot lock the branch reference. A retry should solve it. + GitReferenceLockedError = Class.new(::Gitlab::SidekiqMiddleware::RetryError) + data_consistency :always feature_category :source_code_management @@ -20,11 +23,10 @@ module Projects delete_service_result = ::Branches::DeleteService.new(project, user) .execute(branch_name) - return unless Feature.enabled?(:track_and_raise_delete_source_errors, project) # Only want to raise on 400 to avoid permission and non existant branch error return unless delete_service_result[:http_status] == 400 - delete_service_result.track_and_raise_exception + delete_service_result.log_and_raise_exception(as: GitReferenceLockedError) end end end diff --git a/app/workers/projects/finalize_project_statistics_refresh_worker.rb b/app/workers/projects/finalize_project_statistics_refresh_worker.rb new file mode 100644 index 00000000000..d8b06f55c38 --- /dev/null +++ b/app/workers/projects/finalize_project_statistics_refresh_worker.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Projects + class FinalizeProjectStatisticsRefreshWorker + include ApplicationWorker + + data_consistency :always + + loggable_arguments 0, 1 + + # The increments in `ProjectStatistics` are owned by several teams depending + # on the counter + feature_category :not_owned # rubocop:disable Gitlab/AvoidFeatureCategoryNotOwned + + urgency :low + deduplicate :until_executing, including_scheduled: true + + idempotent! + + def perform(record_class, record_id) + if record_class.demodulize == 'BuildArtifactsSizeRefresh' + Gitlab::ApplicationContext.push(feature_category: :build_artifacts) + end + + return unless self.class.const_defined?(record_class) + + record = record_class.constantize.find_by_id(record_id) + return unless record + + record.finalize! + end + end +end diff --git a/app/workers/projects/git_garbage_collect_worker.rb b/app/workers/projects/git_garbage_collect_worker.rb index 9ac3953e83c..8c0100dd05b 100644 --- a/app/workers/projects/git_garbage_collect_worker.rb +++ b/app/workers/projects/git_garbage_collect_worker.rb @@ -7,12 +7,6 @@ module Projects private - # Used for getting a project/group out of the resource in order to scope a feature flag - # Can be removed within https://gitlab.com/gitlab-org/gitlab/-/issues/353607 - def container(resource) - resource - end - override :find_resource def find_resource(id) Project.find(id) diff --git a/app/workers/projects/refresh_build_artifacts_size_statistics_worker.rb b/app/workers/projects/refresh_build_artifacts_size_statistics_worker.rb index 705bf0534f7..ec23bde5898 100644 --- a/app/workers/projects/refresh_build_artifacts_size_statistics_worker.rb +++ b/app/workers/projects/refresh_build_artifacts_size_statistics_worker.rb @@ -11,6 +11,10 @@ module Projects idempotent! + MAX_RUNNING_LOW = 1 + MAX_RUNNING_MEDIUM = 3 + MAX_RUNNING_HIGH = 5 + def perform_work(*args) refresh = Projects::RefreshBuildArtifactsSizeStatisticsService.new.execute return unless refresh @@ -33,8 +37,12 @@ module Projects end def max_running_jobs - if ::Feature.enabled?(:projects_build_artifacts_size_refresh, type: :ops) - 10 + if ::Feature.enabled?(:projects_build_artifacts_size_refresh_high, type: :ops) + MAX_RUNNING_HIGH + elsif ::Feature.enabled?(:projects_build_artifacts_size_refresh_medium, type: :ops) + MAX_RUNNING_MEDIUM + elsif ::Feature.enabled?(:projects_build_artifacts_size_refresh, type: :ops) + MAX_RUNNING_LOW else 0 end |