-
Notifications
You must be signed in to change notification settings - Fork 669
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
Refactor low node utilization #384
Refactor low node utilization #384
Conversation
cf94218
to
7cf77a4
Compare
041d3ce
to
e9c1975
Compare
@seanmalloy @damemi @lixiang233 PTAL
|
e9c1975
to
a3d47fc
Compare
I don't see anything wrong with these changes. @lixiang233 please review again when you have some time. Thanks! |
/lgtm @lixiang233 please review one more time when you get a chance. Thanks! |
@seanmalloy this change looks pretty good to me. |
/assign @damemi |
/kind cleanup |
a06ae4b
to
acf8857
Compare
acf8857
to
432b674
Compare
432b674
to
f4a55cb
Compare
@seanmalloy done PTAL |
/lgtm |
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.
@ingvagabund could you add some more description to the commits/PR on what the goal is with this refactor, for future reference?
Description updated. Lemme know whether it's sufficient. |
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.
This is definitely one of the more complex strategies and I'm thankful for the improvements to quality and readability @ingvagabund. Just a couple comments to make sure my understanding is correct
func(node *v1.Node, usage NodeUsage) bool { | ||
if nodeutil.IsNodeUnschedulable(node) { | ||
klog.V(2).InfoS("Node is unschedulable, thus not considered as underutilized", "node", klog.KObj(node)) | ||
return false | ||
} | ||
return isNodeWithLowUtilization(usage) | ||
}, | ||
func(node *v1.Node, usage NodeUsage) bool { | ||
return isNodeAboveTargetUtilization(usage) | ||
}, |
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.
is it necessary to pass functions here? The checks seem simple enough that they could just be hardcoded into classifyNodes
, unless something else is going to be re-using it with different filters
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.
It's a preparation for HighNodeUtilization strategy where the upper/lower threshold conditions are different
tj += value | ||
} | ||
} | ||
ti := nodes[i].usage[v1.ResourceMemory].Value() + nodes[i].usage[v1.ResourceCPU].MilliValue() + nodes[i].usage[v1.ResourcePods].Value() |
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.
do these still make sense to add together now that you're storing absolute values instead of percentages? Like if I have a node with 500 pods, 1 mem, 1 cpu
that will be ranked higher usage than 10 pods, 100 mem, 100 cpu
right? But idk if that's a reasonable comparison
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 kept the original computation. Though, it might be better to rather carry addition over relative units. E.g. pods/totalpods + cpu/totalcpu + memory/totalmemory. So nodes with higher percentage of consumed resources have higher priority over those with lower percentage. As a feature we might allow to set weight for each resource. E.g. in case memory is more expensive than cpu.
f4a55cb
to
9b4f781
Compare
@damemi please take a look when you have some time. I believe @ingvagabund has addressed all of your review feedback. /lgtm |
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.
/approve
Thanks @ingvagabund !
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: damemi, ingvagabund 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 |
…node-utilization Refactor low node utilization
Each time a pod's resource consumption is translated into a fraction (number in (0; 1) interval), some precision is lost. Instead, summing all resource consumption absolutely allows to compute the resource usage precisely (up to rounding losses when using Quantity type).
Storing resources consumption into a map of Quantities also allows to simplify arguments of functions used in the code.