mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #99613 from xh4n3/master
fix wrong NumCPU in kube-proxy under static CPU policy
This commit is contained in:
commit
0849d1bea1
@ -24,7 +24,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
goruntime "runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -784,7 +783,7 @@ func getConntrackMax(config kubeproxyconfig.KubeProxyConntrackConfiguration) (in
|
|||||||
if config.Min != nil {
|
if config.Min != nil {
|
||||||
floor = int(*config.Min)
|
floor = int(*config.Min)
|
||||||
}
|
}
|
||||||
scaled := int(*config.MaxPerCore) * goruntime.NumCPU()
|
scaled := int(*config.MaxPerCore) * detectNumCPU()
|
||||||
if scaled > floor {
|
if scaled > floor {
|
||||||
klog.V(3).Infof("getConntrackMax: using scaled conntrack-max-per-core")
|
klog.V(3).Infof("getConntrackMax: using scaled conntrack-max-per-core")
|
||||||
return scaled, nil
|
return scaled, nil
|
||||||
|
@ -25,9 +25,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
goruntime "runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/cadvisor/machine"
|
||||||
|
"github.com/google/cadvisor/utils/sysfs"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@ -436,6 +439,15 @@ func detectNodeIP(client clientset.Interface, hostname, bindAddress string) net.
|
|||||||
return nodeIP
|
return nodeIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func detectNumCPU() int {
|
||||||
|
// try get numCPU from /sys firstly due to a known issue (https://github.com/kubernetes/kubernetes/issues/99225)
|
||||||
|
_, numCPU, err := machine.GetTopology(sysfs.NewRealSysFs())
|
||||||
|
if err != nil || numCPU < 1 {
|
||||||
|
return goruntime.NumCPU()
|
||||||
|
}
|
||||||
|
return numCPU
|
||||||
|
}
|
||||||
|
|
||||||
func getDetectLocalMode(config *proxyconfigapi.KubeProxyConfiguration) (proxyconfigapi.LocalMode, error) {
|
func getDetectLocalMode(config *proxyconfigapi.KubeProxyConfiguration) (proxyconfigapi.LocalMode, error) {
|
||||||
mode := config.DetectLocalMode
|
mode := config.DetectLocalMode
|
||||||
switch mode {
|
switch mode {
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
goruntime "runtime"
|
||||||
|
|
||||||
// Enable pprof HTTP handlers.
|
// Enable pprof HTTP handlers.
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
@ -185,6 +186,10 @@ func getProxyMode(proxyMode string, kcompat winkernel.KernelCompatTester) string
|
|||||||
return proxyModeUserspace
|
return proxyModeUserspace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func detectNumCPU() int {
|
||||||
|
return goruntime.NumCPU()
|
||||||
|
}
|
||||||
|
|
||||||
func tryWinKernelSpaceProxy(kcompat winkernel.KernelCompatTester) string {
|
func tryWinKernelSpaceProxy(kcompat winkernel.KernelCompatTester) string {
|
||||||
// Check for Windows Kernel Version if we can support Kernel Space proxy
|
// Check for Windows Kernel Version if we can support Kernel Space proxy
|
||||||
// Check for Windows Version
|
// Check for Windows Version
|
||||||
|
Loading…
Reference in New Issue
Block a user