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

runc-facade: squashes rare runc errors #14259

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion components/docker-up/docker-up/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var aptUpdated = false
const (
dockerSocketFN = "/var/run/docker.sock"
gitpodUserId = 33333
containerIf = "ceth0"
)

func main() {
Expand Down Expand Up @@ -135,7 +136,6 @@ func runWithinNetns() (err error) {
}
args = append(args, userArgs...)

containerIf := "ceth0"
netIface, err := netlink.LinkByName(containerIf)
if err != nil {
return xerrors.Errorf("cannot get container network device %s: %w", containerIf, err)
Expand Down
16 changes: 12 additions & 4 deletions components/docker-up/runc-facade/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"golang.org/x/xerrors"
)

const RETRY = 3

var (
defaultOOMScoreAdj = 1000
)
Expand Down Expand Up @@ -86,9 +88,15 @@ func createAndRunc(runcPath string, log *logrus.Logger) error {
}
}

err = syscall.Exec(runcPath, os.Args, os.Environ())
if err != nil {
return xerrors.Errorf("exec %s: %w", runcPath, err)
// See here for more details on why retries are necessary.
// https://github.com/gitpod-io/gitpod/issues/12365
for i := 0; i <= RETRY; i++ {
err = syscall.Exec(runcPath, os.Args, os.Environ())
if err == nil {
return err
} else {
log.WithError(err).Warn("runc failed")
}
}
return nil
return xerrors.Errorf("exec %s: %w", runcPath, err)
}
18 changes: 14 additions & 4 deletions components/image-builder-bob/cmd/runc-facade/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import (
"path/filepath"
"syscall"

"github.com/gitpod-io/gitpod/common-go/log"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"golang.org/x/xerrors"
)

const RETRY = 2

func main() {
log := logrus.New()
log.SetLevel(logrus.DebugLevel)
Expand Down Expand Up @@ -95,9 +98,16 @@ func createAndRunc(runcPath, bundle string) error {
}
}

err = syscall.Exec(runcPath, os.Args, os.Environ())
if err != nil {
return xerrors.Errorf("exec %s: %w", runcPath, err)
// See here for more details on why retries are necessary.
// https://github.com/gitpod-io/gitpod/issues/12365
for i := 0; i <= RETRY; i++ {
err = syscall.Exec(runcPath, os.Args, os.Environ())
if err == nil {
return err
} else {
log.WithError(err).Warn("runc failed")
}
}
return nil

return xerrors.Errorf("exec %s: %w", runcPath, err)
}