You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Repository navigation
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
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
in Deployment/StatefulSet/DaemonSet apps/v1beta1 or extensions/v1beta1, spec.selector is not mandatory.
If it is not specified, it is generated from spec.metadata.labels
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:
Ideally, Helm should be aware of selector (explicit or generated)
Note that charts using v1beta1, not having explicit selector, and don't have mutable fields (i.e no chart or version) in spec.template.metadata.labels are not impacted.
Thankfully, this can be solved using a minor version change.
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?
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.
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[/+]on Sep 18, 2018
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[/+]on Sep 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.
Activity
desaintmartin commentedon Sep 13, 2018
cc @mattfarina @davidkarlsen @scottrigby @javsalgar @carrodher
scottrigby commentedon 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?
apps/v1beta1orextensions/v1beta1require explicitly adding match labels - including the mutablechartlabel (this issue, Putting chart version in metadata.labels in a Deployment v1beta1 without selector prevents upgrade #7726).>=apps/v1require removing any mutable labels fromspec.selector, specificallychart(Putting chart version in spec.selector.matchLabels in apps/v1beta2 and later prevents ANY future upgrade of existing Release #7680).If so, should we clarify this in #7692?
And can this issue should clarify this line in the "Conclusion":
For this issue (resources in
apps/v1beta1orextensions/v1beta1), it sounds like "set selector everywhere" is correct, but adding a mutable fields is exactly what we want them to do here?desaintmartin commentedon Sep 14, 2018
Hey @scottrigby, just helping!
You are correct, except that, in my understanding, the immutability comes with
apps/v1beta2and later, and not onlyapps/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/v1beta1orextensions/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.
[-]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[/+][-]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[/+]Add a matchLabels selector to stateful sets as well
Add a matchLabels selector to stateful sets as well
stale commentedon 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.
desaintmartin commentedon Oct 19, 2018
Have all charts been updated? Can we close this?
carrodher commentedon Oct 23, 2018
Charts owned by Bitnami were updated
[stable/postgresql] Fix upgradability of metrics deployment. (#9119)
jkirkham-ratehub commentedon Dec 17, 2018
I've also encountered this issue in the
stable/mongodbchart. It doesn't appear to be fixed yet (https://github.com/helm/charts/tree/master/stable/mongodb).desaintmartin commentedon Dec 18, 2018
It is related to #7680 to be exact, thanks for reporting.
juan131 commentedon Jan 2, 2019
MongoDB chart was fixed on this PR: #10121
[stable/postgresql] Fix upgradability of metrics deployment. (helm#9119)
scottrigby commentedon Feb 11, 2019
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 😄