diff --git a/pkg/server/container_status.go b/pkg/server/container_status.go index 3c494410d..50e56fe2e 100644 --- a/pkg/server/container_status.go +++ b/pkg/server/container_status.go @@ -40,7 +40,7 @@ func (c *criContainerdService) ContainerStatus(ctx context.Context, r *runtime.C // * ImageSpec in container config is image ID. // * ImageSpec in container status is image tag. // * ImageRef in container status is repo digest. - spec := container.Metadata.Config.GetImage() + spec := container.Config.GetImage() imageRef := container.ImageRef image, err := c.imageStore.Get(imageRef) if err != nil { diff --git a/pkg/server/events.go b/pkg/server/events.go index 74c552558..6815b1999 100644 --- a/pkg/server/events.go +++ b/pkg/server/events.go @@ -57,9 +57,13 @@ func newEventMonitor(c *containerstore.Store, s *sandboxstore.Store) *eventMonit } } -// subscribe starts subsribe containerd events. We separate subscribe from +// subscribe starts to subscribe containerd events. func (em *eventMonitor) subscribe(client *containerd.Client) { - em.ch, em.errCh = client.Subscribe(em.ctx) + filters := []string{ + `topic=="/tasks/exit"`, + `topic=="/tasks/oom"`, + } + em.ch, em.errCh = client.Subscribe(em.ctx, filters...) } // start starts the event monitor which monitors and handles all container events. It returns @@ -74,7 +78,7 @@ func (em *eventMonitor) start() (<-chan struct{}, error) { for { select { case e := <-em.ch: - logrus.Debugf("Received container event timestamp - %v, namespace - %q, topic - %q", e.Timestamp, e.Namespace, e.Topic) + logrus.Debugf("Received containerd event timestamp - %v, namespace - %q, topic - %q", e.Timestamp, e.Namespace, e.Topic) em.handleEvent(e) case err := <-em.errCh: logrus.WithError(err).Error("Failed to handle event stream")