BigW Consortium Gitlab

Commit c46417c5 by Alessio Caiazza

Rename App to Applications

parent 880cf60b
module Clusters
module Concerns
end
end
module Clusters module Clusters
module Applications
class BaseHelmService class BaseHelmService
attr_accessor :app attr_accessor :app
...@@ -20,4 +21,5 @@ module Clusters ...@@ -20,4 +21,5 @@ module Clusters
@helm_api ||= Gitlab::Kubernetes::Helm.new(kubeclient) @helm_api ||= Gitlab::Kubernetes::Helm.new(kubeclient)
end end
end end
end
end end
module Clusters module Clusters
class CheckAppInstallationProgressService < BaseHelmService module Applications
class CheckInstallationProgressService < BaseHelmService
def execute def execute
return unless app.installing? return unless app.installing?
FetchAppInstallationStatusService.new(app).execute do |phase, log| FetchInstallationStatusService.new(app).execute do |phase, log|
case phase case phase
when 'Succeeded' when 'Succeeded'
if app.make_installed if app.make_installed
FinalizeAppInstallationService.new(app).execute FinalizeInstallationService.new(app).execute
else else
app.make_errored!("Failed to update app record; #{app.errors}") app.make_errored!("Failed to update app record; #{app.errors}")
end end
when 'Failed' when 'Failed'
app.make_errored!(log || 'Installation silently failed') app.make_errored!(log || 'Installation silently failed')
FinalizeAppInstallationService.new(app).execute FinalizeInstallationService.new(app).execute
else else
if Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT if Time.now.utc - app.updated_at.to_time.utc > ClusterWaitForAppInstallationWorker::TIMEOUT
app.make_errored!('App installation timeouted') app.make_errored!('App installation timeouted')
...@@ -25,4 +26,5 @@ module Clusters ...@@ -25,4 +26,5 @@ module Clusters
end end
end end
end end
end
end end
module Clusters module Clusters
class FetchAppInstallationStatusService < BaseHelmService module Applications
class FetchInstallationStatusService < BaseHelmService
def execute def execute
return unless app.installing? return unless app.installing?
...@@ -10,4 +11,5 @@ module Clusters ...@@ -10,4 +11,5 @@ module Clusters
app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored? app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored?
end end
end end
end
end end
module Clusters module Clusters
class FinalizeAppInstallationService < BaseHelmService module Applications
class FinalizeInstallationService < BaseHelmService
def execute def execute
helm_api.delete_installation_pod!(app) helm_api.delete_installation_pod!(app)
...@@ -12,4 +13,5 @@ module Clusters ...@@ -12,4 +13,5 @@ module Clusters
app.installing? || app.scheduled? app.installing? || app.scheduled?
end end
end end
end
end end
module Clusters module Clusters
class InstallAppService < BaseHelmService module Applications
class InstallService < BaseHelmService
def execute def execute
return unless app.scheduled? return unless app.scheduled?
...@@ -19,4 +20,5 @@ module Clusters ...@@ -19,4 +20,5 @@ module Clusters
end end
end end
end end
end
end end
class ClusterInstallAppWorker class ClusterInstallAppWorker
include Sidekiq::Worker include Sidekiq::Worker
include ClusterQueue include ClusterQueue
include ClusterApp include ClusterApplications
def perform(app_name, app_id) def perform(app_name, app_id)
find_app(app_name, app_id) do |app| find_application(app_name, app_id) do |app|
Clusters::InstallAppService.new(app).execute Clusters::Applications::InstallService.new(app).execute
end end
end end
end end
class ClusterWaitForAppInstallationWorker class ClusterWaitForAppInstallationWorker
include Sidekiq::Worker include Sidekiq::Worker
include ClusterQueue include ClusterQueue
include ClusterApp include ClusterApplications
INITIAL_INTERVAL = 30.seconds INITIAL_INTERVAL = 30.seconds
EAGER_INTERVAL = 10.seconds EAGER_INTERVAL = 10.seconds
TIMEOUT = 20.minutes TIMEOUT = 20.minutes
def perform(app_name, app_id) def perform(app_name, app_id)
find_app(app_name, app_id) do |app| find_application(app_name, app_id) do |app|
Clusters::CheckAppInstallationProgressService.new(app).execute Clusters::Applications::CheckInstallationProgressService.new(app).execute
end end
end end
end end
module ClusterApp module ClusterApplications
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
def find_app(app_name, id) def find_application(app_name, id, &blk)
Clusters::Cluster::APPLICATIONS[app_name].find(id).try do |app| Clusters::Cluster::APPLICATIONS[app_name].find(id).try(&blk)
yield(app) if block_given?
end
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment