mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
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:
parent
d3b3e8bee6
commit
9f8d1baa57
@ -38,7 +38,7 @@ func startContainer(ctx context.Context, s *service, c *container) error {
|
|||||||
go watchSandbox(s)
|
go watchSandbox(s)
|
||||||
|
|
||||||
// Start watching for oom events
|
// Start watching for oom events
|
||||||
go watchOOMEvents(s)
|
go watchOOMEvents(ctx, s)
|
||||||
} else {
|
} else {
|
||||||
_, err := s.sandbox.StartContainer(c.id)
|
_, err := s.sandbox.StartContainer(c.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package containerdshim
|
package containerdshim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -128,14 +129,14 @@ func watchSandbox(s *service) {
|
|||||||
// No need to send async events here.
|
// No need to send async events here.
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchOOMEvents(s *service) {
|
func watchOOMEvents(ctx context.Context, s *service) {
|
||||||
if s.sandbox == nil {
|
if s.sandbox == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
containerID, err := s.sandbox.GetOOMEvent()
|
containerID, err := s.sandbox.GetOOMEvent()
|
||||||
|
@ -2389,9 +2389,8 @@ func (k *kataAgent) getOOMEvent() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
oomEvent, ok := result.(*grpc.OOMEvent)
|
if oomEvent, ok := result.(*grpc.OOMEvent); ok {
|
||||||
if ok {
|
return oomEvent.ContainerId, nil
|
||||||
return oomEvent.ContainerId, err
|
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user