Skip to content

Commit

Permalink
store: retry RemoveAll on EBUSY
Browse files Browse the repository at this point in the history
when running on NFS, a RemoveAll could cause EBUSY because of some
unlinked files that are still kept open and "silly renamed" to
.nfs$ID.

These files could be kept open by conmon and the issue is addressed
by: containers/conmon#300

Before failing, attempt a few more times.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Sep 29, 2021
1 parent b2e6925 commit 7f8eaef
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
)

var (
Expand Down Expand Up @@ -2498,7 +2499,15 @@ func (s *store) DeleteContainer(id string) error {
gcpath := filepath.Join(s.GraphRoot(), middleDir, container.ID)
wg.Add(1)
go func() {
errChan <- os.RemoveAll(gcpath)
var err error
for attempts := 0; attempts < 50; attempts++ {
err = os.RemoveAll(gcpath)
if err == nil || !errors.Is(err, unix.EBUSY) {
break
}
time.Sleep(time.Millisecond * 100)
}
errChan <- err
wg.Done()
}()

Expand Down

0 comments on commit 7f8eaef

Please sign in to comment.