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

Commit

Permalink
virtcontainers: fix delete sandbox failed problem
Browse files Browse the repository at this point in the history
fixes: #2882

reason: If error happens after container create and before sandbox
updateResouce in the `CreateContainer()`, then delete sandbox
forcefully will return error because s.config.Containers config not
flushed into persist store.

Signed-off-by: jiangpengfei <[email protected]>
  • Loading branch information
flyflypeng committed Aug 11, 2020
1 parent bdcd2dd commit 22d4823
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,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")
}
}
}
}()
Expand Down

0 comments on commit 22d4823

Please sign in to comment.