From c863d680295f74bc8decb296ea44e0c13d88b4d8 Mon Sep 17 00:00:00 2001 From: Marcelo de Castro Loebens Date: Tue, 26 Nov 2024 08:49:51 -0400 Subject: [PATCH] Fix CLI behavior change for Helm v > 3.3.1 Helm introduced changes in the CLI behavior for the command 'helm repo add' in versions superior to 3.3.1. For reference: https://github.com/helm/helm/issues/8771 . This caused the code inside platform::helm::repository to return an error when repos are updated, which in turn makes the puppet manifest fail. The previous behavior can be achieved by using the flag 'force-update' introduced by Helm. However, this is not backwards compatible, so it's usage is conditioned to the software version to decrease the chance of issues during upgrades from stx 8.0. Test plan: PASS: Bootstrap DC + SX subcloud. PASS: Switch http_port to 80 (default is 8080). Verified that the puppet manifest executed successfully. Verified that helm repos were updated. PASS: Switch https_enabled to false. Verified that Horizon is accessible using the port 80. Story: 2011266 Task: 51407 Change-Id: I5dd0a5ac1914073a6e500cd9dde602aa63b874eb Signed-off-by: Marcelo de Castro Loebens --- .../src/modules/platform/manifests/helm.pp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/puppet-manifests/src/modules/platform/manifests/helm.pp b/puppet-manifests/src/modules/platform/manifests/helm.pp index 3a3d09aab..354254a3d 100644 --- a/puppet-manifests/src/modules/platform/manifests/helm.pp +++ b/puppet-manifests/src/modules/platform/manifests/helm.pp @@ -8,6 +8,7 @@ define platform::helm::repository ( $repo_base = undef, $repo_port = undef, $create = false, + $sw_version = undef, ) { $repo_path = "${repo_base}/${name}" @@ -35,10 +36,20 @@ define platform::helm::repository ( $require_relationship = User['sysadmin'] } + # Helm versions above 3.3.1 have a breaking change, where 'helm repo add' now returns an + # error if the repo already exists (reference: https://github.com/helm/helm/issues/8771). + # The 'force-update' flag is enough to overcome this, but it isn't backward compatible. + # TODO(mdecastr): Cleanup once upgrade from 22.12 isn't possible (keep 'force-update') + if $sw_version == '22.12'{ + $base_cmd = 'helm repo add' + } else { + $base_cmd = 'helm repo add --force-update' + } + exec { "Adding StarlingX helm repo: ${name}": before => $before_relationship, environment => [ 'KUBECONFIG=/etc/kubernetes/admin.conf' , 'HOME=/home/sysadmin'], - command => "helm repo add ${name} http://127.0.0.1:${repo_port}/helm_charts/${name}", + command => "${base_cmd} ${name} http://127.0.0.1:${repo_port}/helm_charts/${name}", logoutput => true, user => 'sysadmin', group => 'sys_protected', @@ -49,14 +60,16 @@ define platform::helm::repository ( class platform::helm::repositories inherits ::platform::helm::repositories::params { include ::openstack::horizon::params + include ::platform::params include ::platform::users Anchor['platform::services'] -> platform::helm::repository { $helm_repositories: - repo_base => $target_helm_repos_base_dir, - repo_port => $::openstack::horizon::params::http_port, - create => $::is_initial_config, + repo_base => $target_helm_repos_base_dir, + repo_port => $::openstack::horizon::params::http_port, + create => $::is_initial_config, + sw_version => $::platform::params::software_version, } -> exec { 'Updating info of available charts locally from chart repo':