Skip to content

Commit 49a54e2

Browse files
author
Kazuyoshi Kato
committed
Stats() shouldn't assume s.container is non-nil
Like other exported methods, Stats() shouldn't assume s.container is non-nil. Fixes containerd#7468. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 2716289 commit 49a54e2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

runtime/v2/runc/v1/service.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,11 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (*pt
596596
}
597597

598598
func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.StatsResponse, error) {
599-
cgx := s.container.Cgroup()
599+
container, err := s.getContainer()
600+
if err != nil {
601+
return nil, err
602+
}
603+
cgx := container.Cgroup()
600604
if cgx == nil {
601605
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "cgroup does not exist")
602606
}

0 commit comments

Comments
 (0)