Skip to content

Commit

Permalink
Merge pull request kubernetes#106332 from bobbypage/disable-memcg-not…
Browse files Browse the repository at this point in the history
…ifier

kubelet: cgroupv2 disable memcg notifications
  • Loading branch information
k8s-ci-robot committed Nov 13, 2021
2 parents c1b9ada + f5140d3 commit e4c7951
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/kubelet/eviction/threshold_notifier_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sync"
"time"

libcontainercgroups "github.com/opencontainers/runc/libcontainer/cgroups"
"golang.org/x/sys/unix"
"k8s.io/klog/v2"
)
Expand All @@ -46,6 +47,14 @@ var _ CgroupNotifier = &linuxCgroupNotifier{}
// NewCgroupNotifier returns a linuxCgroupNotifier, which performs cgroup control operations required
// to receive notifications from the cgroup when the threshold is crossed in either direction.
func NewCgroupNotifier(path, attribute string, threshold int64) (CgroupNotifier, error) {
// cgroupv2 does not support monitoring cgroup memory thresholds using cgroup.event_control.
// Instead long term, on cgroupv2 kubelet should rely on combining usage of memory.low on root pods cgroup with inotify notifications on memory.events and or PSI pressure.
// For now, let's return a fake "disabled" cgroup notifier on cgroupv2.
// https://github.com/kubernetes/kubernetes/issues/106331
if libcontainercgroups.IsCgroup2UnifiedMode() {
return &disabledThresholdNotifier{}, nil
}

var watchfd, eventfd, epfd, controlfd int
var err error
watchfd, err = unix.Open(fmt.Sprintf("%s/%s", path, attribute), unix.O_RDONLY|unix.O_CLOEXEC, 0)
Expand Down Expand Up @@ -183,3 +192,9 @@ func (n *linuxCgroupNotifier) Stop() {
unix.Close(n.epfd)
close(n.stop)
}

// disabledThresholdNotifier is a fake diasbled threshold notifier that performs no-ops.
type disabledThresholdNotifier struct{}

func (*disabledThresholdNotifier) Start(_ chan<- struct{}) {}
func (*disabledThresholdNotifier) Stop() {}

0 comments on commit e4c7951

Please sign in to comment.