-
Notifications
You must be signed in to change notification settings - Fork 16.8k
Putting chart version in spec.selector.matchLabels in apps/v1beta2 and later prevents ANY future upgrade of existing Release #7680
Comments
I've edited the issue because it is even wider than I thought: most of v1beta1 charst are broken as well. |
Thanks for linking this issue to the original k8s PR (kubernetes/kubernetes#50719). In the the charts documentation issue (#7692) I was thinking it may be a good idea to link to the relevant section(s) in the k8s documentation instead, since that’s more readable. But as I'm looking through the k8s docs, it seems like the details may be a bit complicated, and your findings so far don't seem to match the documentation. For example: From https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#label-selector-updates:
And also in https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#selector
But your findings show that this happened with And this doesn't seem to be fully documented on all affected resources (I couldn't find any mention of this for Anyway, I'm noting this here rather than the documentation issue #7692 because I'm not sure we have correct notes to link to that are consistent with your findings on this problem - they may also not be comprehensive (of all affected resources). This may be a separate k8s documentation issue if it turns out to be the case. |
|
Issue updated to source from documentation. Still no source for StatefulSet. |
I have updated the whole issue to only focus on the blocking problem regarding apps/v1beta2 and newer. |
Edited to move the volumeClaimTemplate bug to its own issue since it is different than the selector problem: #7803 |
…by removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (#7687) See #7680. Signed-off-by: Cédric de Saint Martin <[email protected]>
…removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (#7686) Also set a selector to all Deployments. See #7680. Signed-off-by: Cédric de Saint Martin <[email protected]>
cc @cheyang for horovod. |
…by removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (helm#7687) See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]> Signed-off-by: jenkin-x <[email protected]>
…by removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (helm#7687) See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]> Signed-off-by: Jakob Niggel <[email protected]>
…removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (helm#7686) Also set a selector to all Deployments. See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]> Signed-off-by: Jakob Niggel <[email protected]>
…elm#8596) See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]> Signed-off-by: Jakob Niggel <[email protected]>
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. |
AFAIK no more charts have this problem, closing. |
Monogodb is still impacted, see their statefulset with |
I just created this PR to fix it @desaintmartin |
…by removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (helm#7687) See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]>
…removing 'chart' label from spec.selector or spec.VolumeClaimTemplate. (helm#7686) Also set a selector to all Deployments. See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]>
…elm#8596) See helm#7680. Signed-off-by: Cédric de Saint Martin <[email protected]>
1. Upgrade the Kubernetes API versions to the latest stable ones 2. Remove the mutable label for helm release upgrade, related issue: helm/charts#7680 Signed-off-by: Wenkai Yin <[email protected]>
This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See helm/charts#7680 for more details
…c.selector.matchLabels (#622) This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See helm/charts#7680 for more details
…c.selector.matchLabels (#622) This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See helm/charts#7680 for more details
…c.selector.matchLabels (#622) This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See helm/charts#7680 for more details
…c.selector.matchLabels (#622) This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See helm/charts#7680 for more details
…c.selector.matchLabels (elastic#622) This fix metricbeat chart upgrades when .Chart.Version change. UPGRADE FAILED Error: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable Error: UPGRADE FAILED: Deployment.apps "metricbeat-metricbeat-metrics" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app":"metricbeat-metricbeat-metrics", "chart":"metricbeat-7.7.0", "heritage":"Tiller", "release":"metricbeat"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable See helm/charts#7680 for more details
BUG REPORT
tl;dr: any Chart containing Deployment/StatefulSet/DaemonSet apps/v1beta2 or newer using a chart version in a selector or other immutable field can't be upgraded
Edit:
This is the second bug among 3 regarding "I can't upgrade my Release".
Forewords
Immutability
Deployment
since apps/v1beta2,spec.selector.matchLabels
. Sources:Official documentation: https://v1-8.docs.kubernetes.io/docs/concepts/workloads/controllers/deployment/
PR introducing the feature: Make selector immutable for v1beta2 deployment, replicaset and daemonset prior update kubernetes/kubernetes#50719
DaemonSet
, since apps/v1beta2,spec.selector.matchLabels
StatefulSet
, everything exceptspec.replicas
,spec.template
, andspec.updateStrategy
(i.espec.selector
andspec.VolumeClaimTemplate
is immutable)Required selector
Since Deployments, StatefulSet or DaemonSet apps/v1beta2, spec.selector.matchLabels is mandatory. Sources:
Official documentation: https://v1-8.docs.kubernetes.io/docs/concepts/workloads/controllers/deployment/
In previous versions it was generated from
spec.metadata.labels
. Source:Official documentation: https://v1-7.docs.kubernetes.io/docs/concepts/workloads/controllers/deployment/
This means that for apps/v1beta2 or newer, every change of an existing
Deployment
,StatefulSet
orDaemonSet
inspec.selector.mathLabels
or other immutable fields will be refused by kubernetes.The problem
In some charts, we set the chart version (directly or through the
chart
template) in different parts of the Deployment/StatefulSet/DaemonSet yaml files of the Chart.This causes helm to attempt to change immutable fields and any upgrade (even if it ONLY change the version in Chart.yaml) will fail.
IN OTHER WORDS, SOME CHARTS OF THIS REPOSITORY ARE DEEPLY BROKEN AND CAN'T BE UPGRADED, only installed once.
Impacted charts
At least, impacted charts are:
stable/rabbitmq(fixed in [stable/rabbitmq] Fix chart not being upgradable #7848)stable/redis(fixed in [stable/redis] Major version bump: Fix chart not being upgradable #7686)stable/phpmyadmin(fixed in [stable/phpmyadmin] Fix chart not being upgradable #7830)stable/horovod(fixed in [stable/horovod] Major version bump: Fix chart not being upgradable. #8596)stable/mongodb(partial fix in add selector matchLabels #7441, fixed in [stable/mongodb] Fix chart not being upgradable when replicaset is enabled. #10121)stable/nats(fixed in [stable/nats] Fix chart not being upgradable #7832)How to reproduce (using redis as an example)
For each scenario, disable "cluster" option in values.yaml only for simplicity, install the redis 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, and remove the chart:
1 - Statefulset apps/v1beta2 or newer: spec.selector
Because of templates/redis-master-statefulset.yaml containing:
chart: {{ template "redis.chart" . }}
into
spec.selector
and `spec.template.metadata.labelsIt will cause:
(note that here, metadata.labels.Chart does not cause issue because of explicit selector)
(Edit: previous versions of this issue had other examples, since moved to their own issues)
Let's remove this line, uninstall, then reinstall, upgrade: it works.
Conclusion
tl;dr: don't put fields that may change in selector
This is a really blocking problem, even solving this will require to break impacted charts (major version bump).
The only known workaround is to run
kubectl delete cascade=false
for offending Deployments, StatefulSets or DaemonSets until this is solved, which only kind of works...A lot of PRs going the wrong way have been merged lately (see this one as example: #6909)
And a few attempts without really understanding the problems were tried to solve it: #7441
Helm has several related won't-fix issues: helm/helm#2494
cc @mattfarina
cc helm/chart-testing#19 for testing this
cc https://github.com/helm/charts/issues/3011 to document this
cc #5657 to document solving (a.k.a breaking) this
The text was updated successfully, but these errors were encountered: