From 3745b2be566c0c491fd8fca2afabd7d3e77c5d69 Mon Sep 17 00:00:00 2001 From: Maksim An Date: Tue, 1 Jun 2021 16:44:17 -0700 Subject: [PATCH] [1.0] retry unix.EINTR for container init process When running a script from an azure file share interrupted syscall occurs quite frequently, to remedy this add retries around execve syscall, when EINTR is returned. Signed-off-by: Maksim An (cherry picked from commit e39ad6505995a9e3c098fa4b91d39d266f4e27ba) [Minor conflict in libcontainer/standard_init_linux.go due to missing commit e918d021399e62 -- resolved manually] Signed-off-by: Kir Kolyshkin --- libcontainer/standard_init_linux.go | 2 +- libcontainer/system/linux.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libcontainer/standard_init_linux.go b/libcontainer/standard_init_linux.go index 45c6d66cb..98c486054 100644 --- a/libcontainer/standard_init_linux.go +++ b/libcontainer/standard_init_linux.go @@ -224,7 +224,7 @@ func (l *linuxStandardInit) Init() error { return err } - if err := unix.Exec(name, l.config.Args[0:], os.Environ()); err != nil { + if err := system.Exec(name, l.config.Args[0:], os.Environ()); err != nil { return newSystemErrorWithCause(err, "exec user process") } return nil diff --git a/libcontainer/system/linux.go b/libcontainer/system/linux.go index 4379a2070..b9fd0832d 100644 --- a/libcontainer/system/linux.go +++ b/libcontainer/system/linux.go @@ -35,7 +35,16 @@ func Execv(cmd string, args []string, env []string) error { return err } - return unix.Exec(name, args, env) + return Exec(name, args, env) +} + +func Exec(cmd string, args []string, env []string) error { + for { + err := unix.Exec(cmd, args, env) + if err != unix.EINTR { //nolint:errorlint // unix errors are bare + return err + } + } } func Prlimit(pid, resource int, limit unix.Rlimit) error {