From 429d3e49520d018258460782a5f456125e5610af Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Mon, 12 Nov 2018 12:23:32 +1300 Subject: Update config map if already present on install When an application install fails, and the user retries install, the configmap for the application will already exists. If so, we simply update instead of create. --- lib/gitlab/kubernetes/helm/api.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/kubernetes/helm/api.rb b/lib/gitlab/kubernetes/helm/api.rb index 06841ec7b76..7c026ac9e68 100644 --- a/lib/gitlab/kubernetes/helm/api.rb +++ b/lib/gitlab/kubernetes/helm/api.rb @@ -54,7 +54,11 @@ module Gitlab def create_config_map(command) command.config_map_resource.tap do |config_map_resource| - kubeclient.create_config_map(config_map_resource) + if config_map_exists?(config_map_resource) + kubeclient.update_config_map(config_map_resource) + else + kubeclient.create_config_map(config_map_resource) + end end end @@ -88,6 +92,12 @@ module Gitlab end end + def config_map_exists?(resource) + kubeclient.get_config_map(resource.metadata.name, resource.metadata.namespace) + rescue ::Kubeclient::ResourceNotFoundError + false + end + def service_account_exists?(resource) kubeclient.get_service_account(resource.metadata.name, resource.metadata.namespace) rescue ::Kubeclient::ResourceNotFoundError -- cgit v1.2.1