kube-proxy: detect host CPU count via cpuset.NumCPU instead of cadvisor

detectNumCPU sized nf_conntrack_max using github.com/google/cadvisor/lib
machine topology. nf_conntrack_max is host-wide, so it must be sized from the
node's CPU count, not runtime.NumCPU(): the latter honors the process cpuset
and undercounts when kube-proxy runs under a static CPU policy, which is the
behavior cadvisor worked around (kubernetes/kubernetes#99225).

Use cpuset.NumCPU() from k8s.io/utils, which reads the node's online CPU count
from /sys/devices/system/cpu/online, with a runtime.NumCPU() fallback. This
drops the cadvisor dependency from pkg/proxy/conntrack and bumps k8s.io/utils
to pick up cpuset.NumCPU.

Kubernetes-commit: 92ce184653f03c312915993d7fde93d8e65602c1
This commit is contained in:
Davanum Srinivas
2026-06-25 14:04:01 -04:00
committed by Kubernetes Publisher
parent 729fdbb676
commit a8015da736
2 changed files with 27 additions and 15 deletions
+13 -5
View File
@@ -8,13 +8,13 @@ godebug default=go1.26
require (
golang.org/x/time v0.15.0
k8s.io/api v0.0.0-20260619005804-b846a6a65d1f
k8s.io/apimachinery v0.0.0-20260619005300-111d7ab7ffaf
k8s.io/client-go v0.0.0-20260619010447-d04ac3067ff1
k8s.io/code-generator v0.0.0-20260619011751-49908740568a
k8s.io/api v0.0.0
k8s.io/apimachinery v0.0.0
k8s.io/client-go v0.0.0
k8s.io/code-generator v0.0.0
k8s.io/klog/v2 v2.140.0
k8s.io/kube-openapi v0.0.0-20260618221249-bc653b64f974
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
k8s.io/utils v0.0.0-20260626114624-be93311217bd
sigs.k8s.io/structured-merge-diff/v6 v6.4.0
)
@@ -64,3 +64,11 @@ require (
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
replace (
k8s.io/api => ../api
k8s.io/apimachinery => ../apimachinery
k8s.io/client-go => ../client-go
k8s.io/code-generator => ../code-generator
k8s.io/streaming => ../streaming
)