Class: Clusters::Cleanup::AppService

Inherits:
BaseService show all
Defined in:
app/services/clusters/cleanup/app_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::DEFAULT_EXECUTION_INTERVAL

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Clusters::Cleanup::BaseService

Instance Method Details

#executeObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/clusters/cleanup/app_service.rb', line 6

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