Skip to content

Commit

Permalink
Remove zarf prefix from helm chart release names (#1114)
Browse files Browse the repository at this point in the history
## 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 <[email protected]>
  • Loading branch information
jeff-mccoy and davesee authored Dec 13, 2022
1 parent f412a47 commit beb41a6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions packages/gitea/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/logging-pgl/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/zarf-registry/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 13 additions & 11 deletions src/internal/packager/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/25_helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit beb41a6

Please sign in to comment.