mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Just use runtime.NumCPU on windows
docker folks added NumCPU implementation for windows that supported hot-plugging of CPUs. The implementation used the GetProcessAffinityMask to be able to check which CPUs are active as well.3707a76921
The golang "runtime" package has also bene using GetProcessAffinityMask since 1.6 beta1:6410e67a1e
So we don't seem to need the sysinfo.NumCPU from docker/docker. (Note that this is PR is an effort to get away from dependencies from docker/docker) Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
426e5dc57d
commit
25c3ddf22e
@ -78,7 +78,6 @@ go_library(
|
||||
"//pkg/kubelet/apis:go_default_library",
|
||||
"//pkg/kubelet/winstats:go_default_library",
|
||||
"//vendor/github.com/Microsoft/hcsshim:go_default_library",
|
||||
"//vendor/github.com/docker/docker/pkg/sysinfo:go_default_library",
|
||||
"//vendor/golang.org/x/sys/windows/registry:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
|
@ -20,12 +20,12 @@ package dockershim
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/blang/semver"
|
||||
dockertypes "github.com/docker/docker/api/types"
|
||||
dockercontainer "github.com/docker/docker/api/types/container"
|
||||
dockerfilters "github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"k8s.io/klog"
|
||||
|
||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
@ -75,7 +75,7 @@ func (ds *dockerService) updateCreateConfig(
|
||||
Memory: rOpts.MemoryLimitInBytes,
|
||||
CPUShares: rOpts.CpuShares,
|
||||
CPUCount: rOpts.CpuCount,
|
||||
NanoCPUs: rOpts.CpuMaximum * int64(sysinfo.NumCPU()) * (1e9 / 10000),
|
||||
NanoCPUs: rOpts.CpuMaximum * int64(runtime.NumCPU()) * (1e9 / 10000),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,6 @@ go_library(
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"//pkg/kubelet/apis:go_default_library",
|
||||
"//vendor/github.com/docker/docker/pkg/sysinfo:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
|
@ -20,8 +20,7 @@ package kuberuntime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"runtime"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
@ -85,7 +84,7 @@ func (m *kubeGenericRuntimeManager) generateWindowsContainerConfig(container *v1
|
||||
// https://github.com/opencontainers/runtime-spec/blob/ad53dcdc39f1f7f7472b10aa0a45648fe4865496/config-windows.md#cpu
|
||||
// If both CpuWeight and CpuMaximum are set - ContainerD catches this invalid case and returns an error instead.
|
||||
|
||||
cpuMaximum := 10000 * cpuLimit.MilliValue() / int64(sysinfo.NumCPU()) / 1000
|
||||
cpuMaximum := 10000 * cpuLimit.MilliValue() / int64(runtime.NumCPU()) / 1000
|
||||
|
||||
// TODO: This should be reviewed or removed once Hyper-V support is implemented with CRI-ContainerD
|
||||
// in a future release. cpuCount may or may not be required if cpuMaximum is set.
|
||||
|
Loading…
Reference in New Issue
Block a user