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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2017-11-02 19:52:17 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2017-11-02 19:52:17 +0300
commit94d5f5680e398ddfe0cc621bde00dfb5c8a39d03 (patch)
tree8e5fd7c50de308a93fd218fc962ca81c70b24326 /app/services/clusters
parenta8d7e4bcb13e24426a531ef37d573e24d2547b81 (diff)
Extract ClusterWaitForAppInstallationWorker logic into a service
Diffstat (limited to 'app/services/clusters')
-rw-r--r--app/services/clusters/check_app_installation_progress_service.rb28
-rw-r--r--app/services/clusters/install_app_service.rb2
2 files changed, 29 insertions, 1 deletions
diff --git a/app/services/clusters/check_app_installation_progress_service.rb b/app/services/clusters/check_app_installation_progress_service.rb
new file mode 100644
index 00000000000..ff3398bbd63
--- /dev/null
+++ b/app/services/clusters/check_app_installation_progress_service.rb
@@ -0,0 +1,28 @@
+module Clusters
+ class CheckAppInstallationProgressService < BaseHelmService
+ def execute
+ return unless app.installing?
+
+ FetchAppInstallationStatusService.new(app).execute do |phase, log|
+ case phase
+ when 'Succeeded'
+ if app.make_installed
+ FinalizeAppInstallationService.new(app).execute
+ else
+ app.make_errored!("Failed to update app record; #{app.errors}")
+ end
+ when 'Failed'
+ app.make_errored!(log || 'Installation silently failed')
+ FinalizeAppInstallationService.new(app).execute
+ else
+ if Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT
+ app.make_errored!('App installation timeouted')
+ else
+ ClusterWaitForAppInstallationWorker.perform_in(
+ ClusterWaitForAppInstallationWorker::EAGER_INTERVAL, app.name, app.id)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/services/clusters/install_app_service.rb b/app/services/clusters/install_app_service.rb
index a72cfa0a17f..63f15abaa6d 100644
--- a/app/services/clusters/install_app_service.rb
+++ b/app/services/clusters/install_app_service.rb
@@ -14,7 +14,7 @@ module Clusters
end
rescue KubeException => ke
app.make_errored!("Kubernetes error: #{ke.message}")
- rescue StandardError => e
+ rescue StandardError
app.make_errored!("Can't start installation process")
end
end