Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-13747: 4.13: kubelet/cm: disable cpu load balancing on slices when using static cpu manager policy #1580

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions pkg/kubelet/cm/cgroup_manager_linux.go
Expand Up @@ -38,7 +38,6 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets"
cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util"
"k8s.io/kubernetes/pkg/kubelet/managed"
"k8s.io/kubernetes/pkg/kubelet/metrics"
)

Expand Down Expand Up @@ -148,6 +147,10 @@ type cgroupManagerImpl struct {

// useSystemd tells if systemd cgroup manager should be used.
useSystemd bool

// cpuLoadBalanceDisable tells whether kubelet should disable
// cpu load balancing on new cgroups it creates.
cpuLoadBalanceDisable bool
}

// Make sure that cgroupManagerImpl implements the CgroupManager interface
Expand Down Expand Up @@ -474,10 +477,10 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
utilruntime.HandleError(fmt.Errorf("cgroup manager.Set failed: %w", err))
}

// Disable cpuset.sched_load_balance for all cgroups Kubelet creates when kubelet has workloads to manage.
// Disable cpuset.sched_load_balance for all cgroups Kubelet creates.
// This way, CRI can disable sched_load_balance for pods that must have load balance
// disabled, but the slices can contain all cpus (as the guaranteed cpus are known dynamically).
if managed.IsEnabled() && !libcontainercgroups.IsCgroup2UnifiedMode() {
if m.cpuLoadBalanceDisable && !libcontainercgroups.IsCgroup2UnifiedMode() {
path := manager.Path("cpuset")
if path == "" {
return fmt.Errorf("Failed to find cpuset for newly created cgroup")
Expand Down Expand Up @@ -572,3 +575,7 @@ func (m *cgroupManagerImpl) MemoryUsage(name CgroupName) (int64, error) {
val, err := fscommon.GetCgroupParamUint(path, file)
return int64(val), err
}

func (m *cgroupManagerImpl) SetCPULoadBalanceDisable() {
m.cpuLoadBalanceDisable = true
}
3 changes: 3 additions & 0 deletions pkg/kubelet/cm/cgroup_manager_unsupported.go
Expand Up @@ -77,6 +77,9 @@ func (m *unsupportedCgroupManager) ReduceCPULimits(cgroupName CgroupName) error
return nil
}

func (m *unsupportedCgroupManager) SetCPULoadBalanceDisable() {
}

var RootCgroupName = CgroupName([]string{})

func NewCgroupName(base CgroupName, components ...string) CgroupName {
Expand Down
3 changes: 3 additions & 0 deletions pkg/kubelet/cm/container_manager_linux.go
Expand Up @@ -250,6 +250,9 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
// Turn CgroupRoot from a string (in cgroupfs path format) to internal CgroupName
cgroupRoot := ParseCgroupfsToCgroupName(nodeConfig.CgroupRoot)
cgroupManager := NewCgroupManager(subsystems, nodeConfig.CgroupDriver)
if nodeConfig.CPUManagerPolicy == string(cpumanager.PolicyStatic) {
cgroupManager.SetCPULoadBalanceDisable()
}
// Check if Cgroup-root actually exists on the node
if nodeConfig.CgroupsPerQOS {
// this does default to / when enabled, but this tests against regressions.
Expand Down
2 changes: 2 additions & 0 deletions pkg/kubelet/cm/types.go
Expand Up @@ -84,6 +84,8 @@ type CgroupManager interface {
ReduceCPULimits(cgroupName CgroupName) error
// MemoryUsage returns current memory usage of the specified cgroup, as read from the cgroupfs.
MemoryUsage(name CgroupName) (int64, error)
// Toggle whether CPU load balancing should be disabled for new cgroups the kubelet creates
SetCPULoadBalanceDisable()
}

// QOSContainersInfo stores the names of containers per qos
Expand Down