mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-17 15:38:00 +00:00
Merge pull request #2346 from bergwolf/hostdir
shimv2: clean up properly if vmm quits unexpectedly
This commit is contained in:
commit
68fc9abc5e
@ -17,11 +17,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func deleteContainer(ctx context.Context, s *service, c *container) error {
|
func deleteContainer(ctx context.Context, s *service, c *container) error {
|
||||||
if !c.cType.IsSandbox() {
|
status, err := s.sandbox.StatusContainer(c.id)
|
||||||
status, err := s.sandbox.StatusContainer(c.id)
|
if err != nil && !isNotFound(err) {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
}
|
if !c.cType.IsSandbox() && err == nil {
|
||||||
if status.State.State != types.StateStopped {
|
if status.State.State != types.StateStopped {
|
||||||
_, err = s.sandbox.StopContainer(c.id, false)
|
_, err = s.sandbox.StopContainer(c.id, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1096,13 +1096,6 @@ func (c *Container) stop(force bool) error {
|
|||||||
// get failed if the process hasn't exited.
|
// get failed if the process hasn't exited.
|
||||||
c.sandbox.agent.waitProcess(c, c.id)
|
c.sandbox.agent.waitProcess(c, c.id)
|
||||||
|
|
||||||
// container was killed by force, container MUST change its state
|
|
||||||
// as soon as possible just in case one of below operations fail leaving
|
|
||||||
// the containers in a bad state.
|
|
||||||
if err := c.setContainerState(types.StateStopped); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
// Save device and drive data.
|
// Save device and drive data.
|
||||||
// TODO: can we merge this saving with setContainerState()?
|
// TODO: can we merge this saving with setContainerState()?
|
||||||
@ -1133,6 +1126,13 @@ func (c *Container) stop(force bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// container was killed by force, container MUST change its state
|
||||||
|
// as soon as possible just in case one of below operations fail leaving
|
||||||
|
// the containers in a bad state.
|
||||||
|
if err := c.setContainerState(types.StateStopped); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user