Merge pull request #11439 from k8s-infra-cherrypick-robot/cherry-pick-11433-to-release/2.0

[release/2.0] pkg: prevent oom watcher from depending on shim pkg
This commit is contained in:
Akihiro Suda 2025-02-27 17:46:32 +09:00 committed by GitHub
commit 1bdee2c4b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -25,9 +25,9 @@ import (
"github.com/containerd/cgroups/v3/cgroup1"
eventstypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/v2/core/events"
"github.com/containerd/containerd/v2/core/runtime"
"github.com/containerd/containerd/v2/pkg/oom"
"github.com/containerd/containerd/v2/pkg/shim"
"github.com/containerd/containerd/v2/pkg/sys"
"github.com/containerd/log"
"golang.org/x/sys/unix"
@ -35,7 +35,7 @@ import (
// New returns an epoll implementation that listens to OOM events
// from a container's cgroups.
func New(publisher shim.Publisher) (oom.Watcher, error) {
func New(publisher events.Publisher) (oom.Watcher, error) {
fd, err := unix.EpollCreate1(unix.EPOLL_CLOEXEC)
if err != nil {
return nil, err
@ -52,7 +52,7 @@ type epoller struct {
mu sync.Mutex
fd int
publisher shim.Publisher
publisher events.Publisher
set map[uintptr]*item
}

View File

@ -24,15 +24,15 @@ import (
cgroupsv2 "github.com/containerd/cgroups/v3/cgroup2"
eventstypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/v2/core/events"
"github.com/containerd/containerd/v2/core/runtime"
"github.com/containerd/containerd/v2/pkg/oom"
"github.com/containerd/containerd/v2/pkg/shim"
"github.com/containerd/log"
)
// New returns an implementation that listens to OOM events
// from a container's cgroups.
func New(publisher shim.Publisher) (oom.Watcher, error) {
func New(publisher events.Publisher) (oom.Watcher, error) {
return &watcher{
itemCh: make(chan item),
publisher: publisher,
@ -42,7 +42,7 @@ func New(publisher shim.Publisher) (oom.Watcher, error) {
// watcher implementation for handling OOM events from a container's cgroup
type watcher struct {
itemCh chan item
publisher shim.Publisher
publisher events.Publisher
}
type item struct {