From 25bce7c970a7d3712436f512c91b7119a0770a87 Mon Sep 17 00:00:00 2001 From: Igor Soares Date: Mon, 27 Mar 2023 19:40:25 -0400 Subject: [PATCH] Fix temporary chart directory name for helm 3.9.4 The temporary chart directory created during the Helm overrides generation process now comply with Helm naming rule: chart directories must be lower case letters and numbers only. This ensures that directories created for temporary chart files are compatible with Helm 3.9.4 and beyond. Test Plan: PASS: build-pkgs --clean --all PASS: full AIO-SX deployment PASS: nginx-ingress-controller successfully uploaded/applied PASS: cert-manager successfully uploaded/applied PASS: platform-integ-apps successfully uploaded/applied PASS: oidc-auth-apps successfully uploaded/applied PASS: app-istio successfully uploaded/applied/removed/deleted PASS: app-kubevirt successfully uploaded/applied/removed/deleted PASS: app-oran-o2 successfully uploaded/applied/removed/deleted PASS: app-security-profiles-operator successfully uploaded/applied/removed/deleted PASS: app-sriov-fec-operator successfully uploaded/applied/removed/deleted PASS: app-sts-silicom successfully uploaded/applied/removed/deleted PASS: audit-armada-app successfully uploaded/applied/removed/deleted PASS: metrics-server-armada-app successfully uploaded/applied/removed/deleted PASS: ptp-notification-armada-app successfully uploaded/applied/removed/deleted PASS: snmp-armada-app successfully uploaded/applied/removed/deleted PASS: vault-armada-app successfully uploaded/applied/removed/deleted Story: 2010677 Task: 47758 Signed-off-by: Igor Soares Change-Id: Idba770dcc4b3210320eac0d83088cf311098b339 --- sysinv/sysinv/sysinv/sysinv/helm/utils.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sysinv/sysinv/sysinv/sysinv/helm/utils.py b/sysinv/sysinv/sysinv/sysinv/helm/utils.py index b72ba28489..da7fac1907 100644 --- a/sysinv/sysinv/sysinv/sysinv/helm/utils.py +++ b/sysinv/sysinv/sysinv/sysinv/helm/utils.py @@ -14,6 +14,8 @@ import os import psutil import ruamel.yaml as yaml import tempfile +import random +import string import threading import zlib @@ -164,6 +166,23 @@ def delete_helm_release(release, namespace="default", flags=None): timer.cancel() +def create_tmp_chart_dir(): + """ Create a helm-compatible temporary chart directory + + Chart directory names must have only lower cases letters and + numbers in order to be accepted as valid by Helm. + + :returns: full path of the temporary directory created + """ + + dir_name = ''.join(random.choices( + string.ascii_lowercase + string.digits, k=32)) + dir_path = os.path.join(tempfile.gettempdir(), dir_name) + os.mkdir(dir_path) + + return dir_path + + def install_helm_chart_with_dry_run(args=None): """Simulate a chart install @@ -183,7 +202,7 @@ def install_helm_chart_with_dry_run(args=None): timer = None try: # Make a temporary directory with a fake chart in it - tmpdir = tempfile.mkdtemp() + tmpdir = create_tmp_chart_dir() chartfile = tmpdir + '/Chart.yaml' with open(chartfile, 'w') as tmpchart: tmpchart.write('name: mychart\napiVersion: v1\n'