2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Clusters
|
|
|
|
module Applications
|
2019-12-04 20:38:33 +05:30
|
|
|
class CheckInstallationProgressService < CheckProgressService
|
2018-03-17 18:26:18 +05:30
|
|
|
private
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
def operation_in_progress?
|
|
|
|
app.installing? || app.updating?
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def on_success
|
|
|
|
app.make_installed!
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
Gitlab::Tracking.event('cluster:applications', "cluster_application_#{app.name}_installed")
|
2018-03-17 18:26:18 +05:30
|
|
|
ensure
|
|
|
|
remove_installation_pod
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_timeout
|
2019-07-31 22:56:46 +05:30
|
|
|
if timed_out?
|
2018-03-17 18:26:18 +05:30
|
|
|
begin
|
2019-03-02 22:35:43 +05:30
|
|
|
app.make_errored!("Operation timed out. Check pod logs for #{pod_name} for more details.")
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
else
|
|
|
|
ClusterWaitForAppInstallationWorker.perform_in(
|
|
|
|
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
def pod_name
|
|
|
|
install_command.pod_name
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
def timed_out?
|
2020-05-24 23:13:21 +05:30
|
|
|
Time.current.utc - app.updated_at.utc > ClusterWaitForAppInstallationWorker::TIMEOUT
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def remove_installation_pod
|
2019-03-02 22:35:43 +05:30
|
|
|
helm_api.delete_pod!(pod_name)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|