kubernetes: kube-scheduler: unexpected requestedResource for NodeResourcesFit LeastAllocated

What happened?

I have noticed that NodeResourcesFit/LeastAllocated contains unexpectedly high requestedResource compared to NodeResourcesBalancedAllocation (which I guess should be very similar if not identical).

Scenario: I scheduled a pod that runs 1 container and 0 initContainers. It has 5m cpu requirements, and 192Mi memory requirements.

Here is the verbose logging for scorer:

I1130 22:48:39.493033       1 resource_allocation.go:74] "Listing internal info for allocatable resources, requested resources and score" pod="<redacted>" node="<nodename>" resourceAllocationScorer="LeastAllocated" allocatableResource=[8000 14554681344] requestedResource=[5728 13233029120] resourceScore=18
I1130 22:48:39.498716       1 resource_allocation.go:74] "Listing internal info for allocatable resources, requested resources and score" pod="<redacted>" node="<nodename>" resourceAllocationScorer="NodeResourcesBalancedAllocation" allocatableResource=[8000 14554681344] requestedResource=[994 5105516544] resourceScore=88
I1130 22:48:39.499803       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="TaintToleration" node="<nodename>" score=300
I1130 22:48:39.499807       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="NodeAffinity" node="<nodename>" score=0
I1130 22:48:39.499812       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="NodeResourcesFit" node="<nodename>" score=18
I1130 22:48:39.499817       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="VolumeBinding" node="<nodename>" score=0
I1130 22:48:39.499822       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="PodTopologySpread" node="<nodename>" score=200
I1130 22:48:39.499826       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="InterPodAffinity" node="<nodename>" score=0
I1130 22:48:39.499852       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="NodeResourcesBalancedAllocation" node="<nodename>" score=88
I1130 22:48:39.499867       1 schedule_one.go:673] "Plugin scored node for pod" pod="<redacted>" plugin="ImageLocality" node="<nodename>" score=0

As you can see the least allocated one is x5 larger by cpu, and x2.5 larger by memory.

Here is what kubectl describe shows for the node:

Allocated resources:                                                                                                                                                                                                                                                                      
  (Total limits may be over 100 percent, i.e., overcommitted.)                                                                                                                                                                                                                            
  Resource           Requests      Limits                                                                                                                                                                                                                                                 
  --------           --------      ------                                                                                                                                                                                                                                                 
  cpu                989m (12%)    95110m (1188%)                                                                                                                                                                                                                                         
  memory             4677Mi (33%)  24058Mi (173%)                                                                                                                                                                                                                                         
  ephemeral-storage  0 (0%)        0 (0%)                                                                                                                                                                                                                                                 
  hugepages-2Mi      0 (0%)        0 (0%) 

This output matches NodeResourcesBalancedAllocation

The node hosts 63 running containers, and if I manually add their requests for cpu and memory together, my results matches result from describe and NodeResourcesBalancedAllocation.

What did you expect to happen?

I expect both NodeResourcesBalancedAllocation and NodeResourcesFit/LeastAllocated have similar (or identical?) requestedResource.

How can we reproduce it (as minimally and precisely as possible)?

Run kube-scheduler with -v=10 and see if it matches in your environment.

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.5", GitCommit:"93e0d7146fb9c3e9f68aa41b2b4265b2fcdb0a4c", GitTreeState:"clean", BuildDate:"2023-08-24T00:48:26Z", GoVersion:"go1.20.7", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.5", GitCommit:"93e0d7146fb9c3e9f68aa41b2b4265b2fcdb0a4c", GitTreeState:"clean", BuildDate:"2023-08-24T00:42:11Z", GoVersion:"go1.20.7", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

bare metal

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ uname -a
# paste output here
Linux <xxx> 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

kubeadm

Container runtime (CRI) and version (if applicable)

containerd 1.6.25

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 31 (27 by maintainers)

Most upvoted comments

I like the proposal above. I proposed the same thing forever ago. I can’t remember what the arguments against it were.

But if there is no opposition now, I’m happy to support it. @ahg-g @Huang-Wei ?