runtime_vm: set Pid and InitPid for VM runtimes
If Pid or InitPid is not set correctly, then c.Alive()
will return false, and all calls depending on c.Alive()
will fail.
Fixes:
@@ -155,8 +155,10 @@ func (r *runtimeVM) CreateContainer(c *Container, cgroupParent string) (retErr e
createdCh := make(chan error)
go func() {
// Create the container
- if _, err := r.task.Create(r.ctx, request); err != nil {
+ if resp, err := r.task.Create(r.ctx, request); err != nil {
createdCh <- errdefs.FromGRPC(err)
+ } else if err := c.state.SetInitPid(int(resp.Pid)); err != nil {
+ createdCh <- err
}
close(createdCh)
@@ -649,6 +651,7 @@ func (r *runtimeVM) updateContainerStatus(c *Container) error {
c.state.Finished = response.ExitedAt
exitCode := int32(response.ExitStatus)
c.state.ExitCode = &exitCode
+ c.state.Pid = int(response.Pid)
if exitCode != 0 {
oomFilePath := filepath.Join(c.bundlePath, "oom")
