summaryrefslogtreecommitdiff
path: root/app/services/clusters
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2017-11-03 10:02:30 +0100
committerAlessio Caiazza <acaiazza@gitlab.com>2017-11-03 10:57:09 +0100
commit08752e5d742a144ffb1ec7c8e07e7a558774fbfc (patch)
tree8f7f3e698eafccfefcd0312e1c7abbda07fc3325 /app/services/clusters
parentc46417c5064867d72debb15c4e280db24c6ab73c (diff)
downloadgitlab-ce-08752e5d742a144ffb1ec7c8e07e7a558774fbfc.tar.gz
Remove `Clusters::Applications::FetchInstallationStatusService`
Diffstat (limited to 'app/services/clusters')
-rw-r--r--app/services/clusters/applications/check_installation_progress_service.rb64
-rw-r--r--app/services/clusters/applications/fetch_installation_status_service.rb15
-rw-r--r--app/services/clusters/applications/install_service.rb2
3 files changed, 46 insertions, 35 deletions
diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb
index 4e8fd9baaf4..7f5a633b749 100644
--- a/app/services/clusters/applications/check_installation_progress_service.rb
+++ b/app/services/clusters/applications/check_installation_progress_service.rb
@@ -4,26 +4,52 @@ module Clusters
def execute
return unless app.installing?
- FetchInstallationStatusService.new(app).execute do |phase, log|
- case phase
- when 'Succeeded'
- if app.make_installed
- FinalizeInstallationService.new(app).execute
- else
- app.make_errored!("Failed to update app record; #{app.errors}")
- end
- when 'Failed'
- app.make_errored!(log || 'Installation silently failed')
- FinalizeInstallationService.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
+ case installation_phase
+ when Gitlab::Kubernetes::Pod::SUCCEEDED
+ on_succeeded
+ when Gitlab::Kubernetes::Pod::FAILED
+ on_failed
+ else
+ check_timeout
end
+ rescue KubeException => ke
+ app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored?
+ end
+
+ private
+
+ def on_succeeded
+ if app.make_installed
+ finalize_installation
+ else
+ app.make_errored!("Failed to update app record; #{app.errors}")
+ end
+ end
+
+ def on_failed
+ app.make_errored!(log || 'Installation silently failed')
+ finalize_installation
+ end
+
+ def check_timeout
+ if Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT
+ app.make_errored!('App installation timeouted')
+ else
+ ClusterWaitForAppInstallationWorker.perform_in(
+ ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
+ end
+ end
+
+ def finilize_installation
+ FinalizeInstallationService.new(app).execute
+ end
+
+ def installation_phase
+ helm_api.installation_status(app)
+ end
+
+ def installation_errors
+ helm_api.installation_log(app)
end
end
end
diff --git a/app/services/clusters/applications/fetch_installation_status_service.rb b/app/services/clusters/applications/fetch_installation_status_service.rb
deleted file mode 100644
index 3d082485532..00000000000
--- a/app/services/clusters/applications/fetch_installation_status_service.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Clusters
- module Applications
- class FetchInstallationStatusService < BaseHelmService
- def execute
- return unless app.installing?
-
- phase = helm_api.installation_status(app)
- log = helm_api.installation_log(app) if phase == 'Failed'
- yield(phase, log) if block_given?
- rescue KubeException => ke
- app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored?
- end
- end
- end
-end
diff --git a/app/services/clusters/applications/install_service.rb b/app/services/clusters/applications/install_service.rb
index 7fcccb5e78c..5ed0968a98a 100644
--- a/app/services/clusters/applications/install_service.rb
+++ b/app/services/clusters/applications/install_service.rb
@@ -9,7 +9,7 @@ module Clusters
if app.make_installing
ClusterWaitForAppInstallationWorker.perform_in(
- ClusterWaitForAppInstallationWorker::INITIAL_INTERVAL, app.name, app.id)
+ ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
else
app.make_errored!("Failed to update app record; #{app.errors}")
end