Skip to content

Commit 0a5dc02

Browse files
authored
Solidify runc create retries (#18709)
1 parent b57d870 commit 0a5dc02

File tree

1 file changed

+17
-10
lines changed
  • components/docker-up/runc-facade

1 file changed

+17
-10
lines changed

components/docker-up/runc-facade/main.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import (
99
"os"
1010
"os/exec"
1111
"syscall"
12+
"time"
1213

1314
"github.com/opencontainers/runtime-spec/specs-go"
1415
"github.com/sirupsen/logrus"
1516
"golang.org/x/xerrors"
1617
)
1718

18-
const RETRY = 3
19+
const RETRY = 10
1920

2021
var (
2122
defaultOOMScoreAdj = 1000
@@ -81,22 +82,28 @@ func createAndRunc(runcPath string, log *logrus.Logger) error {
8182
if err != nil {
8283
return xerrors.Errorf("cannot encode config.json: %w", err)
8384
}
84-
for _, fn := range []string{"config.json", "/tmp/debug.json"} {
85-
err = os.WriteFile(fn, fc, 0644)
86-
if err != nil {
87-
return xerrors.Errorf("cannot encode config.json: %w", err)
88-
}
85+
err = os.WriteFile("config.json", fc, 0644)
86+
if err != nil {
87+
return xerrors.Errorf("cannot encode config.json: %w", err)
8988
}
9089

9190
// See here for more details on why retries are necessary.
9291
// https://github.com/gitpod-io/gitpod/issues/12365
9392
for i := 0; i <= RETRY; i++ {
94-
err = syscall.Exec(runcPath, os.Args, os.Environ())
95-
if err == nil {
96-
return err
97-
} else {
93+
err = exec.Command(runcPath, os.Args[1:]...).Run()
94+
95+
if err != nil {
9896
log.WithError(err).Warn("runc failed")
97+
98+
// runc creation failures can be caused by timing issues with workspacekit/seccomp notify under load.
99+
// Easing of on the pressure here lowers the likelihood of that error.
100+
// NOTE(cw): glossing over races with delays is bad style, but also pragmatic.
101+
//
102+
// Context: https://linear.app/gitpod/issue/ENG-797/docker-containers-sometimes-fail-to-start
103+
time.Sleep(100 * time.Millisecond)
104+
continue
99105
}
106+
return nil
100107
}
101108
return xerrors.Errorf("exec %s: %w", runcPath, err)
102109
}

0 commit comments

Comments
 (0)