From a35ca06260a337280618da523919b1fd021ca749 Mon Sep 17 00:00:00 2001 From: Shambhavi Srivastava Date: Wed, 7 Dec 2022 12:08:18 -0800 Subject: [PATCH] Adding metrics for exit_status of container in multi-container mode. PiperOrigin-RevId: 493671987 --- pkg/sentry/control/lifecycle.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/sentry/control/lifecycle.go b/pkg/sentry/control/lifecycle.go index 0cd77a01a..7a3c24354 100644 --- a/pkg/sentry/control/lifecycle.go +++ b/pkg/sentry/control/lifecycle.go @@ -336,7 +336,7 @@ func (l *Lifecycle) reap(containerID string, tg *kernel.ThreadGroup) { if err := l.updateContainerState(containerID, stateStopped); err != nil { panic(err) } - eventchannel.Emit(&pb.ContainerExitEvent{ + eventchannel.LogEmit(&pb.ContainerExitEvent{ ContainerId: containerID, ExitStatus: uint32(tg.ExitStatus()), }) @@ -392,6 +392,10 @@ func (l *Lifecycle) GetExitStatus(args *ContainerArgs, status *uint32) error { } *status = uint32(c.tg.ExitStatus()) + eventchannel.LogEmit(&pb.ContainerExitEvent{ + ContainerId: args.ContainerID, + ExitStatus: *status, + }) return nil } @@ -423,7 +427,7 @@ func (l *Lifecycle) Reap(args *ContainerArgs, _ *struct{}) error { // the actual stop is called. This may be a duplicate event, but is // necessary in case the reap goroutine transitions the container to the // stop state before the caller starts observing the event channel. - eventchannel.Emit(&pb.ContainerExitEvent{ + eventchannel.LogEmit(&pb.ContainerExitEvent{ ContainerId: args.ContainerID, ExitStatus: uint32(c.tg.ExitStatus()), })