From 0a66e678bc5de3d3ec1f93b3b7d4038e41cd71cf Mon Sep 17 00:00:00 2001 From: Takeo Sawada Date: Thu, 1 Jun 2023 01:51:29 -0700 Subject: [PATCH] Use local_termination_grace_seconds when testing LinuxSandbox availability A 1s timeout was introduced in checking whether LinuxSandbox is available, to prevent a complete hangup on broken systems. However, it turned out that it occasionally results in misjudging that linux-sandbox being not available. `local_termination_grace_seconds` defaults to 15s, which hopefully gives more headroom and configurability in various setups. Fixes #18071 Closes #18151. PiperOrigin-RevId: 536953768 Change-Id: I5d344ee5bf06cb9b13a2cba9d077f0981f4430a3 --- .../devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java index a50f4ba89f48be..cc0219bc340662 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.events.Reporter; import com.google.devtools.build.lib.exec.TreeDeleter; import com.google.devtools.build.lib.exec.local.LocalEnvProvider; +import com.google.devtools.build.lib.exec.local.LocalExecutionOptions; import com.google.devtools.build.lib.exec.local.PosixLocalEnvProvider; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.SilentCloseable; @@ -94,10 +95,11 @@ public static boolean isSupported(final CommandEnvironment cmdEnv) throws Interr private static boolean computeIsSupported(CommandEnvironment cmdEnv, Path linuxSandbox) throws InterruptedException { + LocalExecutionOptions options = cmdEnv.getOptions().getOptions(LocalExecutionOptions.class); ImmutableList linuxSandboxArgv = LinuxSandboxCommandLineBuilder.commandLineBuilder( linuxSandbox, ImmutableList.of("/bin/true")) - .setTimeout(Duration.ofSeconds(1)) + .setTimeout(options.getLocalSigkillGraceSeconds()) .build(); ImmutableMap env = ImmutableMap.of(); Path execRoot = cmdEnv.getExecRoot();