Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Node Affinity and Node Anti-Affinity enhancement related changes. #98

Merged

Conversation

shivramsrivastava
Copy link
Contributor

Refer #51

Pending:

  • Node Affinity E2E test cases.

@shivramsrivastava shivramsrivastava added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 24, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shivramsrivastava

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 24, 2018
@k8s-ci-robot
Copy link
Contributor

Hi @shivramsrivastava. Thanks for your PR.

I'm waiting for a kubernetes or kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@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 May 24, 2018
@m1093782566
Copy link

/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 May 24, 2018
@shivramsrivastava shivramsrivastava changed the title [WIP] Node Affinity and Node Anti-Affinity enhancement related changes. Node Affinity and Node Anti-Affinity enhancement related changes. May 25, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 25, 2018
@shivramsrivastava
Copy link
Contributor Author

/assign @m1093782566

@m1093782566
Copy link

@shivramsrivastava

A quick question. I find you have changed some existing *.pb.go. I am wondering why since you just added a new protobuf file. What command did you use to generate *.pb.go?

protoc --go_out=. *.proto

?

@nikita15p
Copy link
Contributor

nikita15p commented May 25, 2018

@m1093782566
protoc --go_out=,import_path=$GOPATH/src/github.com/kubernetes-sigs/poseidon/pkg/firmament,plugins=grpc:. *.proto is used for generating *.pb.go

@m1093782566
Copy link

@nikita15p

Thanks for your reply, I am fine with it. I just want a clarification :)

if pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
err := copier.Copy(&nodeSelTerm, pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms)
if err != nil {
glog.Info("NodeSelectorTerm Data could not be copied")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glog.Errorf("NodeSelectorTerm %v could not be copied, err: %v", pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, err)

Copy link
Contributor

@nikita15p nikita15p May 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


err := copier.Copy(&prefSchTerm, pod.Spec.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution)
if err != nil {
glog.Info("PreferredSchedulingTerm Data could not be copied")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. Also, there are some similar cases below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

var prefSchTerm []PreferredSchedulingTerm
if pod.Spec.Affinity != nil {
if pod.Spec.Affinity.NodeAffinity != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unnecessary empty line.

@@ -101,4 +102,6 @@ message TaskDescriptor {
repeated Label labels = 32;
// Resource label selectors
repeated LabelSelector label_selectors = 33;
//Affinity

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it include both node and pod affinity? If so, please just make it clear.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the kubernetes also follow same naming convention ie Affinity being the superset of Node Affinity, Pod Affinity and Pod AntiAffinity.


message PodAffinityTermAntiAff {

LabelSelectorAntiAff labelSelector = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra whitespaces?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


message LabelSelectorAntiAff{

MatchLabelsAntiAff matchLabels = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra whitespaces?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if pod.Spec.Affinity != nil {
if pod.Spec.Affinity.NodeAffinity != nil {
if pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
err := copier.Copy(&nodeSelTerm, pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment the usage of copier.Copy, does it deep copy all the common fields from podSpec to nodeSelTerm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does.

nodeAffinity := len(pod.Affinity.NodeAffinity.HardScheduling.NodeSelectorTerms) > 0 || len(pod.Affinity.NodeAffinity.SoftScheduling) > 0
podAffinity := len(pod.Affinity.PodAffinity.HardScheduling) > 0 || len(pod.Affinity.PodAffinity.SoftScheduling) > 0
podAntiAffinity := len(pod.Affinity.PodAntiAffinity.HardScheduling) > 0 || len(pod.Affinity.PodAntiAffinity.SoftScheduling) > 0
localAffinity := new(firmament.Affinity)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment the localAffinity in firmament because as far as I know there are concepts of node local(topology) in Kubernetes and what's the different between them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localAffinity is just the name of local pointer variable pointing to the type firmament.Affinity used for the Affinity. It is not related to the concepts of local(topology) in Kubernetes.

@m1093782566
Copy link

LGTM overall except some nits.

@m1093782566
Copy link

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 25, 2018
@k8s-ci-robot k8s-ci-robot merged commit 096d0af into kubernetes-retired:master May 25, 2018
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants