summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/clusters/applications/prometheus.rb12
-rw-r--r--app/models/clusters/applications/runner.rb4
-rw-r--r--app/models/clusters/concerns/application_data.rb8
-rw-r--r--app/services/clusters/applications/base_helm_service.rb4
-rw-r--r--app/services/clusters/applications/update_service.rb24
5 files changed, 38 insertions, 14 deletions
diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb
index 26bf73f4dd8..f50adb4693d 100644
--- a/app/models/clusters/applications/prometheus.rb
+++ b/app/models/clusters/applications/prometheus.rb
@@ -52,24 +52,16 @@ module Clusters
)
end
- def upgrade_command(values)
+ def upgrade_command(replaced_values: nil)
::Gitlab::Kubernetes::Helm::UpgradeCommand.new(
name,
version: VERSION,
chart: chart,
rbac: cluster.platform_kubernetes_rbac?,
- files: files_with_replaced_values(values)
+ files: replaced_values ? files_with_replaced_values(replaced_values) : files
)
end
- # Returns a copy of files where the values of 'values.yaml'
- # are replaced by the argument.
- #
- # See #values for the data format required
- def files_with_replaced_values(replaced_values)
- files.merge('values.yaml': replaced_values)
- end
-
def prometheus_client
return unless kube_client
diff --git a/app/models/clusters/applications/runner.rb b/app/models/clusters/applications/runner.rb
index 2cf8d47bded..5b4a5ad8ba1 100644
--- a/app/models/clusters/applications/runner.rb
+++ b/app/models/clusters/applications/runner.rb
@@ -40,13 +40,13 @@ module Clusters
)
end
- def upgrade_command
+ def upgrade_command(replaced_values: nil)
::Gitlab::Kubernetes::Helm::UpgradeCommand.new(
name,
version: VERSION,
rbac: cluster.platform_kubernetes_rbac?,
chart: chart,
- files: files,
+ files: replaced_values ? files_with_replaced_values(replaced_values) : files,
repository: repository
)
end
diff --git a/app/models/clusters/concerns/application_data.rb b/app/models/clusters/concerns/application_data.rb
index 52498f123ff..556bf14888b 100644
--- a/app/models/clusters/concerns/application_data.rb
+++ b/app/models/clusters/concerns/application_data.rb
@@ -24,6 +24,14 @@ module Clusters
end
end
+ # Returns a copy of files where the values of 'values.yaml'
+ # are replaced by the argument.
+ #
+ # See #values for the data format required
+ def files_with_replaced_values(replaced_values)
+ files.merge('values.yaml': replaced_values)
+ end
+
private
def certificate_files
diff --git a/app/services/clusters/applications/base_helm_service.rb b/app/services/clusters/applications/base_helm_service.rb
index 8a71730d5ec..c04fb8914f7 100644
--- a/app/services/clusters/applications/base_helm_service.rb
+++ b/app/services/clusters/applications/base_helm_service.rb
@@ -46,8 +46,8 @@ module Clusters
@install_command ||= app.install_command
end
- def upgrade_command(new_values = "")
- app.upgrade_command(new_values)
+ def upgrade_command(replaced_values: nil)
+ app.upgrade_command(replaced_values: replaced_values)
end
end
end
diff --git a/app/services/clusters/applications/update_service.rb b/app/services/clusters/applications/update_service.rb
new file mode 100644
index 00000000000..fecc13f979d
--- /dev/null
+++ b/app/services/clusters/applications/update_service.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Clusters
+ module Applications
+ class UpdateService < BaseHelmService
+ def execute
+ return if app.updating?
+
+ begin
+ app.make_updating!
+ helm_api.update(upgrade_command)
+
+ ::ClusterWaitForAppUpdateWorker.perform_in(::ClusterWaitForAppUpdateWorker::INTERVAL, app.name, app.id)
+ rescue Kubeclient::HttpError => e
+ log_error(e)
+ app.make_update_errored!("Kubernetes error: #{e.error_code}")
+ rescue StandardError => e
+ log_error(e)
+ app.make_update_errored!("Can't start installation process.")
+ end
+ end
+ end
+ end
+end