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

Commit

Permalink
sandbox: Export Stop() to the API level
Browse files Browse the repository at this point in the history
In order to support use cases such as containerd-shim-v2 where we
would have a long running process holding the sandbox pointer, there
would be no reason to call into the stateless function StopSandbox(),
which would recreate a new sandbox pointer and the corresponding ones
for containers.

Fixes #903

Signed-off-by: Sebastien Boeuf <[email protected]>
  • Loading branch information
Sebastien Boeuf committed Nov 12, 2018
1 parent 6c3e266 commit 109e12a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 1 addition & 6 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,11 @@ func StopSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
defer s.releaseStatelessSandbox()

// Stop it.
err = s.stop()
err = s.Stop()
if err != nil {
return nil, err
}

// Remove the network.
if err := s.removeNetwork(); err != nil {
return nil, err
}

return s, nil
}

Expand Down
1 change: 1 addition & 0 deletions virtcontainers/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type VCSandbox interface {
SetAnnotations(annotations map[string]string) error

Start() error
Stop() error
Pause() error
Resume() error
Release() error
Expand Down
5 changes: 5 additions & 0 deletions virtcontainers/pkg/vcmock/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func (s *Sandbox) Start() error {
return nil
}

// Stop implements the VCSandbox function of the same name.
func (s *Sandbox) Stop() error {
return nil
}

// Pause implements the VCSandbox function of the same name.
func (s *Sandbox) Pause() error {
return nil
Expand Down
11 changes: 8 additions & 3 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,9 @@ func (s *Sandbox) Start() error {
return nil
}

// stop stops a sandbox. The containers that are making the sandbox
// Stop stops a sandbox. The containers that are making the sandbox
// will be destroyed.
func (s *Sandbox) stop() error {
func (s *Sandbox) Stop() error {
span, _ := s.trace("stop")
defer span.Finish()

Expand All @@ -1489,7 +1489,12 @@ func (s *Sandbox) stop() error {
return err
}

return s.setSandboxState(StateStopped)
if err := s.setSandboxState(StateStopped); err != nil {
return err
}

// Remove the network.
return s.removeNetwork()
}

// Pause pauses the sandbox
Expand Down

0 comments on commit 109e12a

Please sign in to comment.