Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry remounting the sandbox chroot as read-only if the mount is busy. #11259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions runsc/cmd/chroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"path"
"path/filepath"
"strings"
"time"

specs "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -187,8 +188,19 @@ func setUpChroot(spec *specs.Spec, conf *config.Config) error {
return fmt.Errorf("error configuring chroot for TPU devices: %w", err)
}

if err := specutils.SafeMount("", chroot, "", unix.MS_REMOUNT|unix.MS_RDONLY|unix.MS_BIND, "", "/proc"); err != nil {
return fmt.Errorf("error remounting chroot in read-only: %v", err)
// NOTE(gvisor.dev/issue/10965): Some systems have intermittent EBUSY errors
// when trying to remount the chroot as read-only. Retry a few times to
// work around this.
for i := 0; i < 3; i++ {
if err := specutils.SafeMount("", chroot, "", unix.MS_REMOUNT|unix.MS_RDONLY|unix.MS_BIND, "", "/proc"); err != nil {
if err == unix.EBUSY && i < 2 {
log.Warningf("chroot mount was busy when trying to remount it as read-only, retrying...")
time.Sleep(50 * time.Millisecond)
continue
}
return fmt.Errorf("error remounting chroot in read-only: %v", err)
}
break
}

return pivotRoot(chroot)
Expand Down
Loading