virtcontainers: tests fix, nit fix

[ port from runtime commit b4833a48c81132e5a6b1c25a764cd0ebbdc6afff ]

fix tests and nit

Signed-off-by: Alex Price <aprice@atlassian.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Alex Price 2020-06-29 01:08:54 -07:00 committed by Peng Tao
parent d3b3e8bee6
commit 9f8d1baa57
3 changed files with 6 additions and 6 deletions

View File

@ -38,7 +38,7 @@ func startContainer(ctx context.Context, s *service, c *container) error {
go watchSandbox(s)
// Start watching for oom events
go watchOOMEvents(s)
go watchOOMEvents(ctx, s)
} else {
_, err := s.sandbox.StartContainer(c.id)
if err != nil {

View File

@ -6,6 +6,7 @@
package containerdshim
import (
"context"
"path"
"time"
@ -128,14 +129,14 @@ func watchSandbox(s *service) {
// No need to send async events here.
}
func watchOOMEvents(s *service) {
func watchOOMEvents(ctx context.Context, s *service) {
if s.sandbox == nil {
return
}
for {
select {
case <-s.ctx.Done():
case <-ctx.Done():
return
default:
containerID, err := s.sandbox.GetOOMEvent()

View File

@ -2389,9 +2389,8 @@ func (k *kataAgent) getOOMEvent() (string, error) {
if err != nil {
return "", err
}
oomEvent, ok := result.(*grpc.OOMEvent)
if ok {
return oomEvent.ContainerId, err
if oomEvent, ok := result.(*grpc.OOMEvent); ok {
return oomEvent.ContainerId, nil
}
return "", err
}