mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-12 03:30:28 +01:00
fix(pregate): only a gstack-pregate process sets the remote gate's deadline
The ancestor walk matched any command line that mentioned gstack-pregate, so a shell line running pregate beside the tests (bash -c '...; bin/gstack-pregate ...') gave the stub gate a 600 s deadline. It now matches only a process whose program, or the script its interpreter runs, is gstack-pregate. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
826a2f0dc4
commit
72443fb064
2 files changed
+8
-5
No files matched your search
@@ -127,8 +127,9 @@ if [ -z "$outer_s" ]; then
|
||||
for _ in 1 2 3 4 5 6 7 8; do
|
||||
{ [ -n "$pid" ] && [ "$pid" -gt 1 ]; } || break
|
||||
cmdline=$(ps -o args= -p "$pid" 2>/dev/null) || break
|
||||
case $cmdline in
|
||||
*gstack-pregate*)
|
||||
read -r arg0 arg1 _ <<<"$cmdline" || true
|
||||
case "${arg0##*/} ${arg1##*/}" in
|
||||
"gstack-pregate "*|*" gstack-pregate")
|
||||
outer_s=$(sed -n 's/.*--timeout[ =]\([0-9][0-9]*\).*/\1/p' <<<"$cmdline")
|
||||
outer_s=${outer_s:-600} outer_from="gstack-pregate --timeout"
|
||||
break ;;
|
||||
|
||||
@@ -321,14 +321,16 @@ describe('pregate-remote.sh keyed path (stub ubi-runner)', () => {
|
||||
expect(fs.readFileSync(f.calls, 'utf8').trim().split('\n')).toHaveLength(1);
|
||||
// Run under a process named gstack-pregate, the deadline is read from its --timeout (600 s when it passes none).
|
||||
const shim = path.join(path.dirname(f.repo), 'gstack-pregate');
|
||||
fs.writeFileSync(shim, '#!/usr/bin/env bash\nexec bash scripts/ubicloud/pregate-remote.sh\n', { mode: 0o755 });
|
||||
const run = (args: string[]) => {
|
||||
const r = Bun.spawnSync(['bash', '-c', '"$0" "$@"; exit $?', shim, ...args], { cwd: f.repo, timeout: 90_000, env: { ...process.env, ...KEY, UBI_SIZE: '', GSTACK_FREE_JOBS: '2',
|
||||
fs.writeFileSync(shim, '#!/usr/bin/env bash\nbash scripts/ubicloud/pregate-remote.sh\n', { mode: 0o755 });
|
||||
const run = (args: string[], via = '"$0" "$@"; exit $?') => {
|
||||
const r = Bun.spawnSync(['bash', '-c', via, shim, ...args], { cwd: f.repo, timeout: 90_000, env: { ...process.env, ...KEY, UBI_SIZE: '', GSTACK_FREE_JOBS: '2',
|
||||
STUB_CALLS: f.calls, STUB_VM_HOME: f.vm, STUB_BIN: f.bin, PREGATE_FILES_FILE: path.join(path.dirname(f.repo), 'files.txt'), PREGATE_TREE: f.tree, PREGATE_SPEND_CAP_USD: '2' } as Record<string, string> });
|
||||
return r.stdout.toString() + r.stderr.toString();
|
||||
};
|
||||
expect(run(['--stage', 'tests', '--remote', '--timeout', '1200'])).toMatch(/told to stop after 106[0-5]s \(gstack-pregate --timeout 1200s minus/);
|
||||
expect(run(['--stage', 'tests', '--remote'])).toMatch(/told to stop after 46[0-5]s \(gstack-pregate --timeout 600s minus/);
|
||||
// An ancestor that only mentions gstack-pregate (a shell line running it beside the gate) is not the enclosing pregate.
|
||||
expect(run([], ': bin/gstack-pregate --timeout 400; bash scripts/ubicloud/pregate-remote.sh; exit $?')).toContain("told to stop after 2520s (the cap's 45 min wall minus 3 min for teardown)");
|
||||
}, 120_000);
|
||||
|
||||
test('the VM environment is bun run test:ubicloud\'s (scripts/ubicloud/test-free.sh), so the two cannot drift', () => {
|
||||
|
||||
Reference in new issue
Block a user