New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix volume node affinity to OR node selector terms #62556

Merged
merged 1 commit into from Apr 16, 2018

Conversation

@msau42
Member

msau42 commented Apr 13, 2018

What this PR does / why we need it:
Fixes node selector terms to be ORed, to be consistent with documentation and Pod.NodeAffinity. Also handles the "node selector term nil or empty matches nothing" behavior.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #62551

Special notes for your reviewer:

Release note:

Fixes issue where PersistentVolume.NodeAffinity.NodeSelectorTerms were ANDed instead of ORed.
@msau42

This comment has been minimized.

Member

msau42 commented Apr 13, 2018

/assign @verult
/cc @liggitt

@@ -282,10 +282,12 @@ func checkVolumeNodeAffinity(pv *v1.PersistentVolume, nodeLabels map[string]stri
if err != nil {
return fmt.Errorf("Failed to parse MatchExpressions: %v", err)
}
if !selector.Matches(labels.Set(nodeLabels)) {
return fmt.Errorf("NodeSelectorTerm %+v does not match node labels", term.MatchExpressions)

This comment has been minimized.

@msau42

msau42 Apr 13, 2018

Member

This needs to be updated when MatchFields is added. Consider using a common validate NodeSelectorTerms function instead.

This comment has been minimized.

@msau42

msau42 Apr 13, 2018

Member

Ok one doesn't exist yet. For the current state, I'll keep it as is, and can cherry pick this to 1.10.

Then when MatchFields is added in 1.11, this function can be updated as well to use a common method. cc @k82cn

This comment has been minimized.

@yastij

yastij Apr 13, 2018

Member

@msau42 @k82cn - I’m fine with this, but I believe we are ANDing for nodeAffinity in the scheduler. This might confuse users.

This comment has been minimized.

@msau42

msau42 Apr 13, 2018

Member

@liggitt pointed out to to me that the scheduler is ORing here, and that is also how it's described in the docs.

This comment has been minimized.

@yastij

yastij Apr 13, 2018

Member

Oh indeed that’s nodeSelector and nodeaffinity that are ANDed. Sorry for the confusion.

This comment has been minimized.

@k82cn

k82cn Apr 15, 2018

Member

Then when MatchFields is added in 1.11, this function can be updated as well to use a common method.

Sure, I'll add a helper func for volume and scheduler :)

@msau42

This comment has been minimized.

Member

msau42 commented Apr 13, 2018

/retest

@verult

This comment has been minimized.

Contributor

verult commented Apr 13, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm label Apr 13, 2018

@liggitt

This comment has been minimized.

Member

liggitt commented Apr 14, 2018

/lgtm

@saad-ali

This comment has been minimized.

Member

saad-ali commented Apr 16, 2018

/approve

@k8s-ci-robot

This comment has been minimized.

Contributor

k8s-ci-robot commented Apr 16, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, msau42, saad-ali, verult

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

The pull request process is described here

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

@saad-ali saad-ali added this to the v1.10 milestone Apr 16, 2018

@k8s-merge-robot

This comment has been minimized.

Contributor

k8s-merge-robot commented Apr 16, 2018

[MILESTONENOTIFIER] Milestone Pull Request Labels Incomplete

@liggitt @msau42 @verult

Action required: This pull request requires label changes. If the required changes are not made within 3 days, the pull request will be moved out of the v1.10 milestone.

kind: Must specify exactly one of kind/bug, kind/cleanup or kind/feature.
priority: Must specify exactly one of priority/critical-urgent, priority/important-longterm or priority/important-soon.
sig owner: Must specify at least one label prefixed with sig/.

Help
@fejta-bot

This comment has been minimized.

fejta-bot commented Apr 16, 2018

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@k8s-merge-robot

This comment has been minimized.

Contributor

k8s-merge-robot commented Apr 16, 2018

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-merge-robot

This comment has been minimized.

Contributor

k8s-merge-robot commented Apr 16, 2018

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-merge-robot k8s-merge-robot merged commit e36fa85 into kubernetes:master Apr 16, 2018

14 of 15 checks passed

Submit Queue Required Github CI test is not green: pull-kubernetes-e2e-gce
Details
cla/linuxfoundation msau42 authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gke Skipped
pull-kubernetes-e2e-kops-aws Job succeeded.
Details
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce Job succeeded.
Details
pull-kubernetes-local-e2e Skipped
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details

k8s-merge-robot added a commit that referenced this pull request Apr 18, 2018

Merge pull request #62735 from msau42/automated-cherry-pick-of-#62556-…
…upstream-release-1.10

Automatic merge from submit-queue.

[1.10] Automated cherry pick of #62556: Fix volume node affinity to OR node selector terms

Cherry pick of #62556 on release-1.10.

#62556: Fix volume node affinity to OR node selector terms

**Release note**:

```release-note
Fixes issue where PersistentVolume.NodeAffinity.NodeSelectorTerms were ANDed instead of ORed.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment