Welcome to mirror list, hosted at ThFree Co, Russian Federation.

app_service.rb « cleanup « clusters « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a7e29c78ea07a026e152ad03b7ba98c8ac64bb0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Clusters
  module Cleanup
    class AppService < Clusters::Cleanup::BaseService
      def execute
        persisted_applications = @cluster.persisted_applications

        persisted_applications.each do |app|
          next unless app.available?
          next unless app.can_uninstall?

          log_event(:uninstalling_app, application: app.class.application_name)
          uninstall_app_async(app)
        end

        # Keep calling the worker untill all dependencies are uninstalled
        return schedule_next_execution(Clusters::Cleanup::AppWorker) if persisted_applications.any?

        log_event(:schedule_remove_project_namespaces)
        cluster.continue_cleanup!
      end

      private

      def uninstall_app_async(application)
        application.make_scheduled!

        Clusters::Applications::UninstallWorker.perform_async(application.name, application.id)
      end
    end
  end
end