Skip to content
This repository has been 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

Closed
desaintmartin opened this issue Sep 13, 2018 · 10 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@desaintmartin
Copy link
Collaborator

desaintmartin commented Sep 13, 2018

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.

@desaintmartin
Copy link
Collaborator Author

@scottrigby
Copy link
Member

scottrigby commented Sep 14, 2018

Hi @desaintmartin Thanks again for working to unpack these related issues.

Just to disambiguate these two issues, are you essentially saying this?


If so, should we clarify this in #7692?

And can this issue should clarify this line in the "Conclusion":

set selector everywhere and don't put mutable fields in it (for forward compatibility)

For this issue (resources in apps/v1beta1 or extensions/v1beta1), it sounds like "set selector everywhere" is correct, but adding a mutable fields is exactly what we want them to do here?

@desaintmartin
Copy link
Collaborator Author

Hey @scottrigby, just helping!
You are correct, except that, in my understanding, the immutability comes with apps/v1beta2 and later, and not only apps/v1. Any confirmation or invalidation would be appreciated! :)

Let me clarify the conclusion by clearly separating the two problems, i.e what should be done now (apps/v1beta1 or extensions/v1beta1) and what is nice for the future (>=v1beta2).

Regarding #7692, I didn't want to get into the details of "why" but let's try, let's continue there for this part of the discussion.

@desaintmartin desaintmartin changed the title Putting chart version in metadata.labels in a Deployment without selector prevents upgrade Putting chart version in metadata.labels in a Deployment v1/beta1 without selector prevents upgrade Sep 18, 2018
@desaintmartin desaintmartin changed the title Putting chart version in metadata.labels in a Deployment v1/beta1 without selector prevents upgrade Putting chart version in metadata.labels in a Deployment v1beta1 without selector prevents upgrade Sep 19, 2018
aduffeck added a commit to cloudfoundry-incubator/fissile that referenced this issue Oct 11, 2018
aduffeck added a commit to cloudfoundry-incubator/fissile that referenced this issue Oct 12, 2018
@stale
Copy link

stale bot commented Oct 19, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

@stale stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 19, 2018
@desaintmartin
Copy link
Collaborator Author

Have all charts been updated? Can we close this?

@stale stale bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 19, 2018
@carrodher
Copy link
Collaborator

Charts owned by Bitnami were updated

k8s-ci-robot pushed a commit that referenced this issue Nov 8, 2018
See #7726.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
@scottrigby scottrigby added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Nov 22, 2018
@jkirkham-ratehub
Copy link

I've also encountered this issue in the stable/mongodb chart. It doesn't appear to be fixed yet (https://github.com/helm/charts/tree/master/stable/mongodb).

@desaintmartin
Copy link
Collaborator Author

It is related to #7680 to be exact, thanks for reporting.

@juan131
Copy link
Collaborator

juan131 commented Jan 2, 2019

MongoDB chart was fixed on this PR: #10121

wgiddens pushed a commit to wgiddens/charts that referenced this issue Jan 18, 2019
See helm#7726.

Signed-off-by: Cédric de Saint Martin <cdesaintmartin@wiremind.fr>
@scottrigby
Copy link
Member

We can close this issue because we have the correct way to handle this documented in the Names and Labels section of the REVIEW_GUIDELINES.

If we want to automate checking for this, we should add to https://github.com/helm/chart-testing 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

5 participants