-
Notifications
You must be signed in to change notification settings - Fork 79
Node Affinity and Node Anti-Affinity enhancement related changes. #98
Node Affinity and Node Anti-Affinity enhancement related changes. #98
Conversation
[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 |
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 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. |
/ok-to-test |
/assign @m1093782566 |
A quick question. I find you have changed some existing
? |
@m1093782566 |
Thanks for your reply, I am fine with it. I just want a clarification :) |
pkg/k8sclient/podwatcher.go
Outdated
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") |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pkg/k8sclient/podwatcher.go
Outdated
|
||
err := copier.Copy(&prefSchTerm, pod.Spec.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution) | ||
if err != nil { | ||
glog.Info("PreferredSchedulingTerm Data could not be copied") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pkg/k8sclient/podwatcher.go
Outdated
var prefSchTerm []PreferredSchedulingTerm | ||
if pod.Spec.Affinity != nil { | ||
if pod.Spec.Affinity.NodeAffinity != nil { | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra whitespaces?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra whitespaces?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
LGTM overall except some nits. |
/lgtm |
Refer #51
Pending: