diff options
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/clusters/applications/check_installation_progress_service.rb | 30 | ||||
-rw-r--r-- | app/services/clusters/applications/finalize_installation_service.rb | 11 |
2 files changed, 23 insertions, 18 deletions
diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb index 1bd5dae0584..69bd3613cce 100644 --- a/app/services/clusters/applications/check_installation_progress_service.rb +++ b/app/services/clusters/applications/check_installation_progress_service.rb @@ -6,7 +6,7 @@ module Clusters case installation_phase when Gitlab::Kubernetes::Pod::SUCCEEDED - finalize_installation + on_success when Gitlab::Kubernetes::Pod::FAILED on_failed else @@ -18,23 +18,39 @@ module Clusters private + def on_success + app.make_installed! + ensure + remove_installation_pod + end + def on_failed app.make_errored!(installation_errors || 'Installation silently failed') - finalize_installation + ensure + remove_installation_pod end def check_timeout - if Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT - app.make_errored!('Installation timeouted') - finalize_installation + if timeouted? + begin + app.make_errored!('Installation timeouted') + ensure + remove_installation_pod + end else ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) end end - def finalize_installation - FinalizeInstallationService.new(app).execute + def timeouted? + Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT + end + + def remove_installation_pod + helm_api.delete_installation_pod!(app) + rescue + # no-op end def installation_phase diff --git a/app/services/clusters/applications/finalize_installation_service.rb b/app/services/clusters/applications/finalize_installation_service.rb deleted file mode 100644 index 292c789b67b..00000000000 --- a/app/services/clusters/applications/finalize_installation_service.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Clusters - module Applications - class FinalizeInstallationService < BaseHelmService - def execute - helm_api.delete_installation_pod!(app) - - app.make_installed! if app.installing? - end - end - end -end |