Skip to content

Commit 36d4d63

Browse files
authored
Merge pull request #465 from keboola/pepa_PST-2131_processTimeout
PST-2131 Allow setting custom job timeout using config
2 parents 18e4613 + 7247302 commit 36d4d63

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/JobFactory/OverridesConfigurationDefinition.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ protected function getRootDefinition(TreeBuilder $treeBuilder): ArrayNodeDefinit
5959
->scalarNode('image_tag')
6060
->beforeNormalization()->always($this->getStringNormalizer())->end()
6161
->end()
62+
->integerNode('process_timeout')
63+
->defaultNull()
64+
->validate()
65+
->ifTrue(fn($v) => $v !== null && $v <= 0)
66+
->thenInvalid('must be greater than 0')
67+
->end()
68+
->end()
6269
->arrayNode('backend')->ignoreExtraKeys(true)
6370
->children()
6471
->scalarNode('type')

tests/JobFactory/OverridesConfigurationDefinitionTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function testValidOverrideFull(): void
5151
unset($expected['variableValuesData']['extra']);
5252
$expected['variableValuesId'] = '123';
5353
$expected['runtime']['tag'] = '1';
54+
$expected['runtime']['process_timeout'] = null;
5455
$expected['runtime']['parallelism'] = null;
5556
self::assertSame($expected, $definition->processData($data));
5657
}
@@ -103,6 +104,33 @@ public function invalidConfigurationProvider(): iterable
103104
],
104105
'message' => '#The value "foo" is not allowed for path "overrides.runtime.executor". Permissible values: null, "dind", "k8sContainers"#',
105106
];
107+
108+
yield 'process_timeout zero' => [
109+
'jobData' => [
110+
'runtime' => [
111+
'process_timeout' => 0,
112+
],
113+
],
114+
'message' => '#^Invalid configuration for path "overrides.runtime.process_timeout": must be greater than 0$#',
115+
];
116+
117+
yield 'process_timeout negative' => [
118+
'jobData' => [
119+
'runtime' => [
120+
'process_timeout' => -10,
121+
],
122+
],
123+
'message' => '#^Invalid configuration for path "overrides.runtime.process_timeout": must be greater than 0$#',
124+
];
125+
126+
yield 'process_timeout float' => [
127+
'jobData' => [
128+
'runtime' => [
129+
'process_timeout' => 10.0,
130+
],
131+
],
132+
'message' => '#^Invalid type for path "overrides.runtime.process_timeout". Expected "int", but got "float".$#',
133+
];
106134
// phpcs:enable Generic.Files.LineLength
107135
}
108136

0 commit comments

Comments
 (0)