8000 Allow timeout propagation for remote actions · coderabbit-test/bazel@eea808c · GitHub
[go: up one dir, main page]

Skip to content

Commit eea808c

Browse files
committed
Allow timeout propagation for remote actions
When building using remote execution, action timeouts sometimes need to be adjusted per action to ensure reasonable timeouts are set. This change will allow better control over how actions behave and encourage users to optimize their actions since the global default timeout does not have to be set to the absolute largest action timeout in the graph. Change-Id: I0ea63787ff7769e25dd597575cbfd7fd1050797e
1 parent fba8603 commit eea808c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private static boolean legalExecInfoKeys(String tag) {
5858
|| tag.startsWith("disable-")
5959
|| tag.startsWith("cpu:")
6060
|| tag.equals(ExecutionRequirements.LOCAL)
61+
|| tag.equals(ExecutionRequirements.TIMEOUT)
6162
|| tag.equals(ExecutionRequirements.WORKER_KEY_MNEMONIC)
6263
|| tag.startsWith("resources:");
6364
}

src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public void testCreateSpawnActionEnvAndExecInfo() throws Exception {
416416
" inputs = ruleContext.files.srcs,",
417417
" outputs = ruleContext.files.srcs,",
418418
" env = {'a' : 'b'},",
419-
" execution_requirements = {'timeout' : '10', 'block-network' : 'foo'},",
419+
" execution_requirements = {'block-network' : 'foo'},",
420420
" mnemonic = 'DummyMnemonic',",
421421
" command = 'dummy_command',",
422422
" progress_message = 'dummy_message')");
@@ -425,10 +425,31 @@ public void testCreateSpawnActionEnvAndExecInfo() throws Exception {
425425
Iterables.getOnlyElement(
426426
ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
427427
assertThat(action.getIncompleteEnvironmentForTesting()).containsExactly("a", "b");
428-
// We expect "timeout" to be filtered by TargetUtils.
429428
assertThat(action.getExecutionInfo()).containsExactly("block-network", "foo");
430429
}
431430

431+
@Test
432+
public void testCreateSpawnActionEnvAndExecInfo_withTimeout() throws Exception {
433+
StarlarkRuleContext ruleContext = createRuleContext("//foo:foo");
434+
setRuleContext(ruleContext);
435+
ev.exec(
436+
"ruleContext.actions.run_shell(",
437+
" inputs = ruleContext.files.srcs,",
438+
" outputs = ruleContext.files.srcs,",
439+
" execution_requirements = {",
440+
" 'timeout': '42',",
441+
" },",
442+
" mnemonic = 'DummyMnemonic',",
443+
" command = 'dummy_command',",
444+
" progress_message = 'dummy_message')");
445+
SpawnAction action =
446+
(SpawnAction)
447+
Iterables.getOnlyElement(
448+
ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
449+
assertThat(action.getExecutionInfo())
450+
.containsExactly("timeout", "42");
451+
}
452+
432453
@Test
433454
public void testCreateSpawnActionEnvAndExecInfo_withWorkerKeyMnemonic() throws Exception {
434455
StarlarkRuleContext ruleContext = createRuleContext("//foo:foo");

0 commit comments

Comments
 (0)
0