-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow to balance nodes using specified labels #3839
Conversation
Welcome @rtnpro! |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rtnpro The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -160,5 +167,10 @@ func IsCloudProviderNodeInfoSimilar(n1, n2 *schedulerframework.NodeInfo, ignored | |||
return false | |||
} | |||
|
|||
fmt.Println(includedLabels, len(includedLabels)) | |||
if len(includedLabels) > 0 && !compareLabels(nodes, includedLabels) { |
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.
Wasn't the #3615 intent to shortcut the full labels comparison (the if !compareLabels(nodes, ignoredLabels)
above) with a comparison over a smaller set of includedLabels
?
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.
You are correct @bpineau . I will fix the PR
a76493f
to
87986aa
Compare
87986aa
to
548a061
Compare
func CreateGenericNodeInfoLabelComparator(labels []string) NodeInfoComparator { | ||
return func(n1, n2 *schedulerframework.NodeInfo) bool { | ||
includedLabels := make(map[string]bool) | ||
for _, l := range labels { | ||
includedLabels[l] = true | ||
} | ||
if !compareLabels([]*schedulerframework.NodeInfo{n1, n2}, includedLabels, make(map[string]bool)) { | ||
return false | ||
} | ||
return IsCloudProviderNodeInfoSimilar(n1, n2, make(map[string]bool)) | ||
} | ||
} | ||
|
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.
As suggested, I created a new comparator
to accept labels
instead of extraIgnoredLabels
, and compare nodes based on the specified labels. This --balancing-labels
arg here bypasses the --balancing-ignored-labels
flag. This also ignores the cloud provider-specific basic ignored flags. This calls for some discussion.
Rather than creating a new comparator
, I'd personally prefer to edit the signature of the current comparator creators to accept an extra argument for labels
in addition to extraIgnoredLabels
, and compare the nodes for matching labels specified in labels
if labels
is not empty. If check fails, then we return, else we proceed to call IsCloudProviderNodeInfoSimilar
, which takes care of ignored labels.
@MaciekPytel please share your thoughts and review here.
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.
I think the second implementation idea doesn't change current behavior at all. Currently every label that is not on ignored-labels list will cause the node groups to compare as different. Checking --balancing-labels
first doesn't change the ultimate result, it just fails the comparison slightly earlier.
My understanding of #3615 is that specifying --balancing-labels
makes comparison treat any label not on the list as ignored-label (current implementation treats any label that is not on ignored list as "balancing labels"). I think that:
- Specifying both
--balancing-labels
and--balancing-ignored-labels
makes no sense. What would be the behavior for any label not on either list?- (if you agree with this logic) we should add validation in main.go that prevents setting both flags at the same time.
- Ignoring cloudprovider labels seems irrelevant when using
--balancing-labels
(since we would be ignoring all labels not on the list). - On the implementation side - calling IsCloudProviderNodeInfoSimilar as-is will not work as far as I can see, since it already has the label check embedded. I think the easiest way is to extract the resources check to a separate function and call that new function if
--balancing-labels are specified
, but there are plenty of other ways to refactor and I don't feel particularly strongly about which is the right one.
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.
👍 to
- Making
--balancing-labels
and--balancing-ignored-labels
mutually exclusive - Ignoring cloudprovider labels irrelevant when using
--balancing-labels
- Yes, we'll need to refactor a underlying implementation of
IsCloudProviderNodeInfoSimilar
as you said. Since this is my first issue on CA, I was a bit hesitant to do much refactoring. Thanks for asserting my thoughts.
@MaciekPytel I pushed some changes to this PR today, as per your last review comments: fd5434f Need a review here. Thanks |
@MaciekPytel could I get a review here? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
Fixes #3615