Skip to content

[Bug] 3.7.0 - Helm generates an incorrect chart tree in some cases #10160

@tavlima

Description

@tavlima

Edit: I initially thought this had to do with the new .Subcharts feature, which I was using, but it seems the problem is unrelated. I updated the title to reflect that.


Let me start by thanking @vflaux and others for this long awaited feature. The sort of call-nested workaround was a pain to use and broken in many scenarios. Thank you all 👍.

That being said, I'm either doing something really wrong here or there is a bug. It seems the .Subcharts are not correctly propagated when using multiple levels of subcharts if importing the same subchart (using different aliases, of course).

You can find my attempt at reproducing the issue here. It may be possible to reproduce it with a smaller example, but that is what I could put together in the time I had available.

The dependencies look like this:

composition <- part (as part1) <- subpart (as subpart1) <- common
                               <- subpart (as subpart2) <- common
            <- part (as part2) <- subpart (as subpart1) <- common
                               <- subpart (as subpart2) <- common

The common chart includes a slightly modified version of the default foo.fullname named template, to highlight the issue (the not_a_string else clause):

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "common.fullname" -}}
  {{- if .Values.fullnameOverride }}
    {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
  {{- else }}
    {{- $name := default .Chart.Name .Values.nameOverride }}
    {{- if typeIs "string" $name }}
      {{- if contains $name .Release.Name }}
        {{- .Release.Name | trunc 63 | trimSuffix "-" }}
      {{- else }}
        {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
      {{- end }}
    {{- else }}
      {{- printf "not_a_string" }}
    {{- end }}
  {{- end }}
{{- end }}

And this is the (unexpected) output of helm template composition (after using helm dep up at all levels, of course):

---
# Source: composition/charts/part1/charts/subpart1/templates/subpart.yaml
subpart:
  title: This is from subpart
  fullname: RELEASE-NAME-subpart1
---
# Source: composition/charts/part1/charts/subpart2/templates/subpart.yaml
subpart:
  title: This is from subpart
  fullname: RELEASE-NAME-subpart2
---
# Source: composition/charts/part1/templates/part.yaml
part:
  title: This is from part
  fullname:
    subpart1: RELEASE-NAME-subpart1
    subpart2: RELEASE-NAME-subpart2
---
# Source: composition/charts/part2/charts/subpart/templates/subpart.yaml
subpart:
  title: This is from subpart
  fullname: RELEASE-NAME-subpart
---
# Source: composition/charts/part2/templates/part.yaml
part:
  title: This is from part
  fullname:
    subpart1: not_a_string
    subpart2: not_a_string
---
# Source: composition/templates/composition.yaml
composition:
  title: This is from the composition
  fullname:
    part1: RELEASE-NAME-part1
    part2: RELEASE-NAME-part2

The fun part: if I change composition's Chart.yaml to change the dependencies order, by aliasing the first part dependency as part2 and the last as part1, it is now the composition/charts/part1/templates/part.yaml that reports the not_a_string values. 🤷‍♂️

Thoughts?


Output of helm version: version.BuildInfo{Version:"v3.7.0", GitCommit:"eeac83883cb4014fe60267ec6373570374ce770b", GitTreeState:"clean", GoVersion:"go1.16.8"}
Output of kubectl version: not deemed relevant
Cloud Provider/Platform (AKS, GKE, Minikube etc.): not deemed relevant

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions