summaryrefslogtreecommitdiff
path: root/app/workers/clusters/cleanup/app_worker.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/clusters/cleanup/app_worker.rb')
-rw-r--r--app/workers/clusters/cleanup/app_worker.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/app/workers/clusters/cleanup/app_worker.rb b/app/workers/clusters/cleanup/app_worker.rb
index 1eedf510ba1..8b2fddd3164 100644
--- a/app/workers/clusters/cleanup/app_worker.rb
+++ b/app/workers/clusters/cleanup/app_worker.rb
@@ -3,13 +3,16 @@
module Clusters
module Cleanup
class AppWorker
- include ApplicationWorker
- include ClusterQueue
- include ClusterApplications
+ include ClusterCleanupMethods
- # TODO: Merge with https://gitlab.com/gitlab-org/gitlab/merge_requests/16954
- # We're splitting the above MR in smaller chunks to facilitate reviews
- def perform
+ def perform(cluster_id, execution_count = 0)
+ Clusters::Cluster.with_persisted_applications.find_by_id(cluster_id).try do |cluster|
+ break unless cluster.cleanup_uninstalling_applications?
+
+ break exceeded_execution_limit(cluster) if exceeded_execution_limit?(execution_count)
+
+ ::Clusters::Cleanup::AppService.new(cluster, execution_count).execute
+ end
end
end
end