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

Closed

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.

Activity

  1. desaintmartin commented on Sep 13, 2018

    @desaintmartin
    CollaboratorAuthor
  2. scottrigby commented on Sep 14, 2018

    @scottrigby
    Member

    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?

  3. desaintmartin commented on Sep 14, 2018

    @desaintmartin
    CollaboratorAuthor

    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.

  4. 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
  5. 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
  6. stale commented on Oct 19, 2018

    @stale

    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.

  7. added
    lifecycle/stale
    on Oct 19, 2018
  8. desaintmartin commented on Oct 19, 2018

    @desaintmartin
    CollaboratorAuthor

    Have all charts been updated? Can we close this?

  9. removed
    lifecycle/stale
    on Oct 19, 2018
  10. carrodher commented on Oct 23, 2018

    @carrodher
    Collaborator

    Charts owned by Bitnami were updated

  11. added
    lifecycle/frozen
    on Nov 22, 2018
  12. jkirkham-ratehub commented on Dec 17, 2018

    @jkirkham-ratehub

    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).

  13. desaintmartin commented on Dec 18, 2018

    @desaintmartin
    CollaboratorAuthor

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

  14. juan131 commented on Jan 2, 2019

    @juan131
    Collaborator

    MongoDB chart was fixed on this PR: #10121

  15. scottrigby commented on Feb 11, 2019

    @scottrigby
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozen

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions