Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3020 from jcvenegas/stable-1.10-backports
Browse files Browse the repository at this point in the history
Stable 1.10 backports
  • Loading branch information
jcvenegas authored Oct 21, 2020
2 parents cfe182d + 6f33f4e commit 7e98d86
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 26 deletions.
64 changes: 38 additions & 26 deletions containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,34 +342,46 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
s.mu.Lock()
defer s.mu.Unlock()

var c *container

c, err = create(ctx, s, r)
if err != nil {
return nil, err
}

c.status = task.StatusCreated

s.containers[r.ID] = c
type Result struct {
container *container
err error
}
ch := make(chan Result, 1)
go func() {
container, err := create(ctx, s, r)
ch <- Result{container, err}
}()

s.send(&eventstypes.TaskCreate{
ContainerID: r.ID,
Bundle: r.Bundle,
Rootfs: r.Rootfs,
IO: &eventstypes.TaskIO{
Stdin: r.Stdin,
Stdout: r.Stdout,
Stderr: r.Stderr,
Terminal: r.Terminal,
},
Checkpoint: r.Checkpoint,
Pid: s.pid,
})
select {
case <-ctx.Done():
return nil, errors.Errorf("create container timeout: %v", r.ID)
case res := <-ch:
if res.err != nil {
return nil, res.err
}
container := res.container
container.status = task.StatusCreated

s.containers[r.ID] = container

s.send(&eventstypes.TaskCreate{
ContainerID: r.ID,
Bundle: r.Bundle,
Rootfs: r.Rootfs,
IO: &eventstypes.TaskIO{
Stdin: r.Stdin,
Stdout: r.Stdout,
Stderr: r.Stderr,
Terminal: r.Terminal,
},
Checkpoint: r.Checkpoint,
Pid: s.pid,
})

return &taskAPI.CreateTaskResponse{
Pid: s.pid,
}, nil
return &taskAPI.CreateTaskResponse{
Pid: s.pid,
}, nil
}
}

// Start a process
Expand Down
9 changes: 9 additions & 0 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,10 @@ func (s *Sandbox) CreateContainer(contConfig ContainerConfig) (VCContainer, erro
if len(s.config.Containers) > 0 {
// delete container config
s.config.Containers = s.config.Containers[:len(s.config.Containers)-1]
// need to flush change to persist storage
if newErr := s.storeSandbox(); newErr != nil {
s.Logger().WithError(newErr).Error("Fail to flush s.config.Containers change into sandbox store")
}
}
if !storeAlreadyExists {
if delerr := c.store.Delete(); delerr != nil {
Expand Down Expand Up @@ -1594,6 +1598,11 @@ func (s *Sandbox) Stop(force bool) error {
return err
}

// Stop communicating with the agent.
if err := s.agent.disconnect(); err != nil && !force {
return err
}

return nil
}

Expand Down

0 comments on commit 7e98d86

Please sign in to comment.