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

add selector matchLabels - #7441

Merged
k8s-ci-robot merged 4 commits into
helm:masterfrom
mostafahussein:selector-issue
Sep 6, 2018
Merged

k8s-ci-robot merged 4 commits into
helm:masterfrom
mostafahussein:selector-issue

Conversation

@mostafahussein

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
This PR fixes the following issue that appeared when I tried to deploy the latest release of mongodb chart 4.2.1

spec.template.metadata.labels: Invalid value: map[string]string{"app":"mongodb", "chart":"mongodb-4.2.1", "release":"testprojectv1"}: `selector` does not match template `labels` : exit status 1

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 30, 2018
@mostafahussein

Copy link
Copy Markdown
Contributor Author

/assign @prydonius

@cpanato

cpanato commented Aug 30, 2018 •

Copy link
Copy Markdown
Member

@mostafahussein you need to bump the version in the Chart.yaml and also sign off your commit (https://www.helm.sh/blog/helm-dco/index.html)

thanks!

Signed-off-by: Mostafa Hussein <[email protected]>
@ey-bot ey-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Aug 30, 2018
@lachie83

Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 31, 2018
@juan131

juan131 commented Aug 31, 2018

Copy link
Copy Markdown
Collaborator

Is spec.selector.matchLabels supported on every K8s API version?

@mostafahussein

Copy link
Copy Markdown
Contributor Author

@juan131 I have not tested it on different versions of APIs but the same syntax is already written in other templates in mongodb chart - the replicaSet setup - e.g. mongodb/templates/poddisruptionbudget-primary-rs.yaml, So I think it's already supported but was missed in the standalone deployment.

@juan131

juan131 commented Aug 31, 2018 •

Copy link
Copy Markdown
Collaborator

Hi @mostafahussein

The main difference on those other templates is that they're using statefulsets instead of deployments. I barely remember that there were some issues with that field on some APIs versions with deployments. However, I can't tell you what version was.

@juan131

juan131 commented Aug 31, 2018

Copy link
Copy Markdown
Collaborator

Anyway, I don't want to block you. I tested and it's working on version 1.11 and 1.10 so it's fine to me.

@desaintmartin

desaintmartin commented Sep 3, 2018 •

Copy link
Copy Markdown
Collaborator

Did that appear on an upgrade of an existing Release? If so, I would suggest NOT adding matchLabels as it will NOT fix your issue.
See helm/helm#2494, probably caused by #6895

For the record, matchLabels is automatically generated from spec.template.metadata.labels if not explicitely set.

@mostafahussein

Copy link
Copy Markdown
Contributor Author

I have not updated an existing mongo installation. I was using an old version of the chart for testing purposes then I have deleted mongodb then tried to use a higher version of the chart. I got this issue after adding matchLabel and reinstall it i was able to use the chart however i got a different issue that exists on the current releases of this chart but i wont discuss it in here as this will be out of scope of the current PR

@desaintmartin

Copy link
Copy Markdown
Collaborator

To be honest, I just deployed a new mongodb (helm install stable/mongodb) and can't reproduce. Can you describe how to reproduce?
I've been hit many times by this problem (but in my case only while trying to upgrade a Chart where the Deployment labels have been updated).

@xasor

xasor commented Sep 4, 2018

Copy link
Copy Markdown
Contributor

Hello,

Same problem here. Thanks for the PR @mostafahussein

@desaintmartin try to install an older chart version and then do "helm upgrade" to the latest one. Like this:

helm install --name to-delete --version 4.2.1 stable/mongodb
helm upgrade --install to-delete stable/mongodb

and check the error

Error: UPGRADE FAILED: Deployment.apps "to-delete-mongodb" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"release":"to-delete", "app":"mongodb", "chart":"mongodb-4.2.2"}: selector does not match template labels

@desaintmartin

Copy link
Copy Markdown
Collaborator

the upgrade problem is (unfortunately) well known (see my previous comments), but is anyone able to reproduce without upgrade?

For the upgrade problem, I would suggest reverting the commit I pointed in an earlier comment. @javsalgar, can you elaborate on this commit or point me to a reference?

@mostafahussein

Copy link
Copy Markdown
Contributor Author

In fact I am using rancher which i can only repeat the same steps as i mentioned before, i am not sure if this considered fresh installation for the chart or not but i am sure that i am not deploying it as an upgrade for an existing installation.

I will try to deploy minikube locally or any other possible way in order to try the chart as a fresh install. Also if someone else was able to deploy the chart and confirm if the issue does not occur that would be helpful.

Adnan Abdulhussein added 2 commits September 6, 2018 10:09
Signed-off-by: Adnan Abdulhussein <[email protected]>
Signed-off-by: Adnan Abdulhussein <[email protected]>
@ey-bot ey-bot added Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). labels Sep 6, 2018
Signed-off-by: Adnan Abdulhussein <[email protected]>
@prydonius

Copy link
Copy Markdown
Member

As far as I can tell, this is a fairly recent regression because we accidentally added a mutable label to the Pod Template labels: https://github.com/helm/charts/pull/6895/files. Thanks for the fix @mostafahussein, I made some changes to remove the mutable label.

@ey-bot ey-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Sep 6, 2018
@prydonius

Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 6, 2018
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mostafahussein, prydonius

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 6, 2018
@k8s-ci-robot
k8s-ci-robot merged commit 98b48cb into helm:master Sep 6, 2018
@ey-bot ey-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Sep 6, 2018
@desaintmartin

Copy link
Copy Markdown
Collaborator

Thanks for removing the chart label!

@prydonius

Copy link
Copy Markdown
Member

@desaintmartin didn't see you also pointed to the introduction of the issue in #6895, thanks!

jicowan pushed a commit to jicowan/charts that referenced this pull request Oct 2, 2018
* add selector matchLabels

Signed-off-by: Mostafa Hussein <[email protected]>

* remove immutable label from selector

Signed-off-by: Adnan Abdulhussein <[email protected]>

* bump chart version

Signed-off-by: Adnan Abdulhussein <[email protected]>
Signed-off-by: jenkin-x <[email protected]>
Jnig pushed a commit to Jnig/charts that referenced this pull request Nov 13, 2018
* add selector matchLabels

Signed-off-by: Mostafa Hussein <[email protected]>

* remove immutable label from selector

Signed-off-by: Adnan Abdulhussein <[email protected]>

* bump chart version

Signed-off-by: Adnan Abdulhussein <[email protected]>
Signed-off-by: Jakob Niggel <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants