Skip to content

Commit fec04fd

Browse files
nixprimegvisor-bot
authored andcommitted
runsc: don't forward GOMAXPROCS environment variable to fsgofers
This is not strictly required for runsc-sandbox since runsc/boot/loader.go:New() unconditionally overrides the default GOMAXPROCS via a call to gomaxprocs.SetBase(). Alternatively, we could filter out the GOMAXPROCS environment variable from all shim invocations of runsc (in e.g. pkg/shim/v1/runsccmd/runsc.go:runsccmd.Runsc.command()). But since said invocations of runsc run in containerd's cgroups and are thus subject to its resource restrictions, it's not clear that this would be better. PiperOrigin-RevId: 828079033
1 parent 2e0758b commit fec04fd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

runsc/container/container.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"os/exec"
2525
"path"
2626
"regexp"
27+
"slices"
2728
"strconv"
2829
"strings"
2930
"syscall"
@@ -1309,6 +1310,10 @@ func (c *Container) createGoferProcess(conf *config.Config, mountHints *boot.Pod
13091310

13101311
// Start with the general config flags.
13111312
cmd := exec.Command(specutils.ExePath, conf.ToFlags()...)
1313+
// Don't forward GOMAXPROCS defaults that apply to this process (in
1314+
// particular, containerd-shim-runsc-v1 passes GOMAXPROCS=2 in
1315+
// v1.service.newCommand()).
1316+
cmd.Env = slices.DeleteFunc(os.Environ(), func(env string) bool { return strings.HasPrefix(env, "GOMAXPROCS=") })
13121317
cmd.SysProcAttr = &unix.SysProcAttr{
13131318
// Detach from session. Otherwise, signals sent to the foreground process
13141319
// will also be forwarded by this process, resulting in duplicate signals.

0 commit comments

Comments
 (0)