From 422168f9f988640d716eb57451215e0d972f4dd3 Mon Sep 17 00:00:00 2001 From: Craig O'Donnell Date: Tue, 26 Sep 2023 11:42:57 -0400 Subject: [PATCH 1/3] clean helm dir before writing --- pkg/apparchive/helm-v1beta2.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/apparchive/helm-v1beta2.go b/pkg/apparchive/helm-v1beta2.go index 7ef4cb7af6..69fa06fefc 100644 --- a/pkg/apparchive/helm-v1beta2.go +++ b/pkg/apparchive/helm-v1beta2.go @@ -73,6 +73,10 @@ type WriteV1Beta2HelmChartsOptions struct { // WriteV1Beta2HelmCharts copies the upstream helm chart archive and rendered values to the helm directory and processes online images (if necessary) func WriteV1Beta2HelmCharts(opts WriteV1Beta2HelmChartsOptions) error { + // clear the previous helm dir before writing + helmDir := opts.Upstream.GetHelmDir(opts.WriteUpstreamOptions) + os.RemoveAll(helmDir) + if opts.KotsKinds == nil || opts.KotsKinds.V1Beta2HelmCharts == nil { return nil } @@ -91,7 +95,7 @@ func WriteV1Beta2HelmCharts(opts WriteV1Beta2HelmChartsOptions) error { } } - chartDir := path.Join(opts.Upstream.GetHelmDir(opts.WriteUpstreamOptions), helmChart.GetDirName()) + chartDir := path.Join(helmDir, helmChart.GetDirName()) if err := os.MkdirAll(chartDir, 0744); err != nil { return errors.Wrap(err, "failed to create chart dir") } From fb3f4321bb994dfc958751764f4387736cda6e99 Mon Sep 17 00:00:00 2001 From: Craig O'Donnell Date: Tue, 26 Sep 2023 12:33:02 -0400 Subject: [PATCH 2/3] add test coverage --- .github/workflows/build-test.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 5946b4430d..edf0d412c2 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -3261,6 +3261,33 @@ jobs: sleep 1 done + # validate that the conditional chart is installed + COUNTER=1 + while [ "$(helm ls -n "$APP_SLUG" | awk 'NR>1{print $1}' | grep my-conditional-chart-release)" == "" ]; do + ((COUNTER += 1)) + if [ $COUNTER -gt 120 ]; then + echo "Timed out waiting for my-conditional-chart-release to be installed" + helm ls -n "$APP_SLUG" + exit 1 + fi + sleep 1 + done + + # toggle the config option to exclude the conditional chart + ./bin/kots set config "$APP_SLUG" install_conditional_chart=false --deploy --namespace "$APP_SLUG" + + # wait for my-conditional-chart-release to be uninstalled + COUNTER=1 + while [ "$(helm ls -n "$APP_SLUG" | awk 'NR>1{print $1}' | grep my-conditional-chart-release)" != "" ]; do + ((COUNTER += 1)) + if [ $COUNTER -gt 120 ]; then + echo "Timed out waiting for my-conditional-chart-release to be uninstalled" + helm ls -n "$APP_SLUG" + exit 1 + fi + sleep 1 + done + - name: Generate support bundle on failure if: failure() From 73e7a710998a20a439595d0fe134b4b58831c953 Mon Sep 17 00:00:00 2001 From: Craig O'Donnell Date: Tue, 26 Sep 2023 13:28:39 -0400 Subject: [PATCH 3/3] fix pr test --- .github/workflows/build-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index edf0d412c2..075047b22c 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -3274,7 +3274,7 @@ jobs: done # toggle the config option to exclude the conditional chart - ./bin/kots set config "$APP_SLUG" install_conditional_chart=false --deploy --namespace "$APP_SLUG" + ./bin/kots set config "$APP_SLUG" install_conditional_chart=0 --deploy --namespace "$APP_SLUG" # wait for my-conditional-chart-release to be uninstalled COUNTER=1