diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/workers/metrics | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/workers/metrics')
-rw-r--r-- | app/workers/metrics/dashboard/prune_old_annotations_worker.rb | 23 | ||||
-rw-r--r-- | app/workers/metrics/dashboard/schedule_annotations_prune_worker.rb | 23 |
2 files changed, 46 insertions, 0 deletions
diff --git a/app/workers/metrics/dashboard/prune_old_annotations_worker.rb b/app/workers/metrics/dashboard/prune_old_annotations_worker.rb new file mode 100644 index 00000000000..2a9ce3bb8e6 --- /dev/null +++ b/app/workers/metrics/dashboard/prune_old_annotations_worker.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Metrics + module Dashboard + class PruneOldAnnotationsWorker + include ApplicationWorker + + DELETE_LIMIT = 10_000 + DEFAULT_CUT_OFF_PERIOD = 2.weeks + + feature_category :metrics + + idempotent! # in the scope of 24 hours + + def perform + stale_annotations = ::Metrics::Dashboard::Annotation.ending_before(DEFAULT_CUT_OFF_PERIOD.ago.beginning_of_day) + stale_annotations.delete_with_limit(DELETE_LIMIT) + + self.class.perform_async if stale_annotations.exists? + end + end + end +end diff --git a/app/workers/metrics/dashboard/schedule_annotations_prune_worker.rb b/app/workers/metrics/dashboard/schedule_annotations_prune_worker.rb new file mode 100644 index 00000000000..cbdd69c6e8c --- /dev/null +++ b/app/workers/metrics/dashboard/schedule_annotations_prune_worker.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Metrics + module Dashboard + class ScheduleAnnotationsPruneWorker + include ApplicationWorker + # rubocop:disable Scalability/CronWorkerContext + # This worker does not perform work scoped to a context + include CronjobQueue + # rubocop:enable Scalability/CronWorkerContext + + feature_category :metrics + + idempotent! # PruneOldAnnotationsWorker worker is idempotent in the scope of 24 hours + + def perform + # Process is split into two jobs to avoid long running jobs, which are more prone to be disrupted + # mid work, which may cause some data not be delete, especially because cronjobs has retry option disabled + PruneOldAnnotationsWorker.perform_async + end + end + end +end |