Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Putting chart version in metadata.labels in a Deployment v1beta1 without selector prevents upgrade #7726

@desaintmartin

Description

@desaintmartin

BUG REPORT

Any Chart containing Deployment/StatefulSet/DaemonSet apps/v1beta1 or extensions/v1beta1 without spec.selector using a chart version in metadata.labels can't be upgraded.

Note:
This is the first bug among 3 regarding "I can't upgrade my Release".
For the apps/v1beta2 problem, see #7680.
For the immutable volumeClaimTemplate in StatefulSet (any version), see #7803

From the k8s documentation

Impacted charts

Probably all of https://github.com/helm/charts/pulls?utf8=%E2%9C%93&q=is%3Apr+%22Add+chart+and+release+labels+in+pods%22+

How to reproduce (using stable/dokuwiki as an example)

Let's install the stable/dokuwiki chart using git, change the version in chart.yaml (example: 1.2.3 -> 1.2.4) without changing anything else, and try to upgrade. See it fail:

cd stable/dokuwiki
helm install --name test .
vim Chart.yaml
helm upgrade test .

Because of metadata.labels in templates/deployment.yaml containing:
chart: {{ template "dokuwiki" . }}
It will fail with:

Error: UPGRADE FAILED: Deployment.apps "test-dokuwiki" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"release":"test", "app":"dokuwiki", "chart":"dokuwiki-2.0.7"}: `selector` does not match template `labels`

I think it comes from the fact that during the initial installation, k8s generated the selector, but during upgrade, both helm and k8s ignore it.

But putting an explicit selector, even if it contains a chart label, will make it upgradable:

  selector:
    matchLabels:
      app: {{ template "dokuwiki.name" . }}
      chart: {{ template "dokuwiki.chart" . }}
      release: {{ .Release.Name | quote }}
helm upgrade test .

It works!

Conclusion

Thankfully, this can be solved using a minor version change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions