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

Commit

Permalink
virtcontainers: Call stopVM() from sandbox.Stop()
Browse files Browse the repository at this point in the history
Now that stopVM() also calls agent.stopSandbox(), we can have the
sandbox Stop() call using stopVM() directly and avoid code duplication.

Fixes: #1011

Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
Samuel Ortiz authored and Eric Ernst committed Jan 7, 2019
1 parent acf833c commit 09168cc
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,10 +1254,12 @@ func (s *Sandbox) stopVM() error {
span, _ := s.trace("stopVM")
defer span.Finish()

s.Logger().Info("Stopping sandbox in the VM")
if err := s.agent.stopSandbox(s); err != nil {
s.Logger().WithError(err).WithField("sandboxid", s.id).Warning("Agent did not stop sandbox")
}

s.Logger().Info("Stopping VM")
return s.hypervisor.stopSandbox()
}

Expand Down Expand Up @@ -1592,12 +1594,7 @@ func (s *Sandbox) Stop() error {
}
}

if err := s.agent.stopSandbox(s); err != nil {
return err
}

s.Logger().Info("Stopping VM")
if err := s.hypervisor.stopSandbox(); err != nil {
if err := s.stopVM(); err != nil {
return err
}

Expand Down

0 comments on commit 09168cc

Please sign in to comment.