@@ -31,6 +31,7 @@ import (
3131 "golang.org/x/net/context"
3232 "k8s.io/apimachinery/pkg/util/clock"
3333
34+ "github.com/containerd/cri/pkg/constants"
3435 ctrdutil "github.com/containerd/cri/pkg/containerd/util"
3536 "github.com/containerd/cri/pkg/store"
3637 containerstore "github.com/containerd/cri/pkg/store/container"
@@ -77,7 +78,6 @@ type backOffQueue struct {
7778// Create new event monitor. New event monitor will start subscribing containerd event. All events
7879// happen after it should be monitored.
7980func newEventMonitor (c * containerstore.Store , s * sandboxstore.Store ) * eventMonitor {
80- // event subscribe doesn't need namespace.
8181 ctx , cancel := context .WithCancel (context .Background ())
8282 return & eventMonitor {
8383 containerStore : c ,
@@ -90,6 +90,8 @@ func newEventMonitor(c *containerstore.Store, s *sandboxstore.Store) *eventMonit
9090
9191// subscribe starts to subscribe containerd events.
9292func (em * eventMonitor ) subscribe (subscriber events.Subscriber ) {
93+ // note: filters are any match, if you want any match but not in namespace foo
94+ // then you have to manually filter namespace foo
9395 filters := []string {
9496 `topic=="/tasks/exit"` ,
9597 `topic=="/tasks/oom"` ,
@@ -130,6 +132,10 @@ func (em *eventMonitor) start() <-chan error {
130132 select {
131133 case e := <- em .ch :
132134 logrus .Debugf ("Received containerd event timestamp - %v, namespace - %q, topic - %q" , e .Timestamp , e .Namespace , e .Topic )
135+ if e .Namespace != constants .K8sContainerdNamespace {
136+ logrus .Debugf ("Ignoring events in namespace - %q" , e .Namespace )
137+ break
138+ }
133139 cID , evt , err := convertEvent (e .Event )
134140 if err != nil {
135141 logrus .WithError (err ).Errorf ("Failed to convert event %+v" , e )
0 commit comments