Use len() instead of telling whether it's nil
Add tests to guarantee that when resourceToWeightMap is nil, scheduler will not crash
Signed-off-by: kerthcet <kerthcet@gmail.com>
In the following code pattern, the log message will get logged with v=0 in JSON
output although conceptually it has a higher verbosity:
if klog.V(5).Enabled() {
klog.Info("hello world")
}
Having the actual verbosity in the JSON output is relevant, for example for
filtering out only the important info messages. The solution is to use
klog.V(5).Info or something similar.
Whether the outer if is necessary at all depends on how complex the parameters
are. The return value of klog.V can be captured in a variable and be used
multiple times to avoid the overhead for that function call and to avoid
repeating the verbosity level.
kubernetes#60525 introduced
Balanced attached node volumes feature gate to include volume
count for prioritizing nodes. The reason for introducing this
flag was its usefulness in Red Hat OpenShift Online environment
which is not being used any more. So, removing the flag
as it helps in maintainability of the scheduler code base
as mentioned at kubernetes#101489 (comment)
NodeInfo.Allocatable.ScalarResources already knows which resources
are scaler. Also, if the resource name is not present,
it's pointless to compute score for a resources the node can not allocate
since nodeInfo.Allocatable.ScalarResources[resource] is zero for the case.
And both leastRequestedScore and mostRequestedScore returns 0 score
for nodes with zero allocatable resource.
The balancedResourceScorer deals only with CPU and memory which
are not scalable resources.