From beb41a68e7ce87f1e5e1b80e233eed849c7b15d4 Mon Sep 17 00:00:00 2001 From: Megamind <882485+jeff-mccoy@users.noreply.github.com> Date: Mon, 12 Dec 2022 18:43:16 -0600 Subject: [PATCH] Remove zarf prefix from helm chart release names (#1114) ## Description Migration from #1035. This PR removes the `zarf -` prefix that is added to the chart's releaseName (or chart name if the releaseName is not present). The side effects of the prefix include inconsistent deployed resource names, especially when sub-charts are used, as illustrated in the related issue. ## Related Issue Fixes #1020 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist before merging - [x] Tests have been added/updated as necessary (add the `needs-tests` label) Co-authored-by: davesee --- .github/workflows/test-upgrade.yml | 1 + packages/gitea/zarf.yaml | 1 + packages/logging-pgl/zarf.yaml | 1 + packages/zarf-registry/zarf.yaml | 2 ++ src/internal/packager/helm/chart.go | 24 +++++++++++++----------- src/test/e2e/25_helm_test.go | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-upgrade.yml b/.github/workflows/test-upgrade.yml index d375792db7..b63e122754 100644 --- a/.github/workflows/test-upgrade.yml +++ b/.github/workflows/test-upgrade.yml @@ -55,4 +55,5 @@ jobs: sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true make test-e2e ARCH=amd64 - name: Save logs + if: always() uses: ./.github/actions/save-logs diff --git a/packages/gitea/zarf.yaml b/packages/gitea/zarf.yaml index 50274d6e0e..3a1f6d19cc 100644 --- a/packages/gitea/zarf.yaml +++ b/packages/gitea/zarf.yaml @@ -14,6 +14,7 @@ components: - connect.yaml charts: - name: gitea + releaseName: zarf-gitea url: https://dl.gitea.io/charts version: 6.0.3 namespace: zarf diff --git a/packages/logging-pgl/zarf.yaml b/packages/logging-pgl/zarf.yaml index a91fe1f6e5..aaed2fe5b9 100644 --- a/packages/logging-pgl/zarf.yaml +++ b/packages/logging-pgl/zarf.yaml @@ -17,6 +17,7 @@ components: - connect.yaml charts: - name: loki-stack + releaseName: zarf-loki-stack url: https://grafana.github.io/helm-charts version: 2.8.7 namespace: zarf diff --git a/packages/zarf-registry/zarf.yaml b/packages/zarf-registry/zarf.yaml index 499664b48e..375fbf21b5 100644 --- a/packages/zarf-registry/zarf.yaml +++ b/packages/zarf-registry/zarf.yaml @@ -32,6 +32,7 @@ components: - name: zarf-seed-registry charts: - name: docker-registry + releaseName: zarf-docker-registry localPath: packages/zarf-registry/chart version: 1.0.0 namespace: zarf @@ -51,6 +52,7 @@ components: - configmap.yaml charts: - name: docker-registry + releaseName: zarf-docker-registry localPath: packages/zarf-registry/chart version: 1.0.0 namespace: zarf diff --git a/src/internal/packager/helm/chart.go b/src/internal/packager/helm/chart.go index 78f85729b4..c76f66ad72 100644 --- a/src/internal/packager/helm/chart.go +++ b/src/internal/packager/helm/chart.go @@ -24,7 +24,6 @@ import ( // InstallOrUpgradeChart performs a helm install of the given chart func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) { - var installedChartName string fromMessage := h.Chart.Url if fromMessage == "" { fromMessage = "Zarf-generated helm chart" @@ -37,11 +36,12 @@ func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) { var output *release.Release - h.ReleaseName = fmt.Sprintf("zarf-%s", h.Chart.Name) - if h.Chart.ReleaseName != "" { - h.ReleaseName = fmt.Sprintf("zarf-%s", h.Chart.ReleaseName) + h.ReleaseName = h.Chart.ReleaseName + + // If no release name is specified, use the chart name + if h.ReleaseName == "" { + h.ReleaseName = h.Chart.Name } - installedChartName = h.ReleaseName // Do not wait for the chart to be ready if data injections are present if len(h.Component.DataInjections) > 0 { @@ -113,7 +113,7 @@ func (h *Helm) InstallOrUpgradeChart() (types.ConnectStrings, string, error) { } // return any collected connect strings for zarf connect - return postRender.connectStrings, installedChartName, nil + return postRender.connectStrings, h.ReleaseName, nil } // TemplateChart generates a helm template from a given chart @@ -137,10 +137,11 @@ func (h *Helm) TemplateChart() (string, error) { client.ClientOnly = true client.IncludeCRDs = true - if h.Chart.ReleaseName != "" { - client.ReleaseName = fmt.Sprintf("zarf-%s", h.Chart.ReleaseName) - } else { - client.ReleaseName = fmt.Sprintf("zarf-%s", h.Chart.Name) + client.ReleaseName = h.Chart.ReleaseName + + // If no release name is specified, use the chart name + if client.ReleaseName == "" { + client.ReleaseName = h.Chart.Name } // Namespace must be specified @@ -197,7 +198,8 @@ func (h *Helm) GenerateChart(manifest types.ZarfManifest) (types.ConnectStrings, // Generate the struct to pass to InstallOrUpgradeChart() h.Chart = types.ZarfChart{ Name: tmpChart.Metadata.Name, - ReleaseName: sha1ReleaseName, + // Preserve the zarf prefix for chart names to match v0.22.x and earlier behavior + ReleaseName: fmt.Sprintf("zarf-%s", sha1ReleaseName), Version: tmpChart.Metadata.Version, Namespace: manifest.Namespace, NoWait: manifest.NoWait, diff --git a/src/test/e2e/25_helm_test.go b/src/test/e2e/25_helm_test.go index 771cbf4efa..59677b2ce3 100644 --- a/src/test/e2e/25_helm_test.go +++ b/src/test/e2e/25_helm_test.go @@ -26,7 +26,7 @@ func TestHelm(t *testing.T) { // Verify multiple helm installs of different release names were deployed kubectlOut, _ := exec.Command("kubectl", "get", "pods", "-n=helm-releasename", "--no-headers").Output() - assert.Contains(t, string(kubectlOut), "zarf-cool-name-podinfo") + assert.Contains(t, string(kubectlOut), "cool-name-podinfo") stdOut, stdErr, err = e2e.execZarfCommand("package", "remove", "test-helm-releasename", "--confirm") require.NoError(t, err, stdOut, stdErr)