prevent oom watcher depend on shim pkg.

Signed-off-by: Lei Liu <liulei.pt@bytedance.com>
This commit is contained in:
Lei Liu 2025-02-25 22:06:15 +08:00 committed by k8s-infra-cherrypick-robot
parent 6b4c4a19f5
commit 0ce93e16a9
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 {