Skip to content

Commit

Permalink
Merge pull request #1106 from giuseppe/attempt-to-solve-podman-11594
Browse files Browse the repository at this point in the history
store: use system.EnsureRemoveAll to rm container
  • Loading branch information
rhatdan authored Jan 14, 2022
2 parents 3c0dfaa + 3e69d9a commit 8034dcc
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2501,23 +2501,29 @@ func (s *store) DeleteContainer(id string) error {
gcpath := filepath.Join(s.GraphRoot(), middleDir, container.ID)
wg.Add(1)
go func() {
var err error
for attempts := 0; attempts < 50; attempts++ {
err = os.RemoveAll(gcpath)
if err == nil || !system.IsEBUSY(err) {
break
}
time.Sleep(time.Millisecond * 100)
defer wg.Done()
// attempt a simple rm -rf first
err := os.RemoveAll(gcpath)
if err == nil {
errChan <- nil
return
}
errChan <- err
wg.Done()
// and if it fails get to the more complicated cleanup
errChan <- system.EnsureRemoveAll(gcpath)
}()

rcpath := filepath.Join(s.RunRoot(), middleDir, container.ID)
wg.Add(1)
go func() {
errChan <- os.RemoveAll(rcpath)
wg.Done()
defer wg.Done()
// attempt a simple rm -rf first
err := os.RemoveAll(rcpath)
if err == nil {
errChan <- nil
return
}
// and if it fails get to the more complicated cleanup
errChan <- system.EnsureRemoveAll(rcpath)
}()

go func() {
Expand Down

0 comments on commit 8034dcc

Please sign in to comment.