From 21177b15c17498acc6bfa4081268c3e42cf6b119 Mon Sep 17 00:00:00 2001 From: Shahar Epstein <60007259+shahar1@users.noreply.github.com> Date: Sat, 4 Jul 2026 18:27:11 +0300 Subject: [PATCH] Rerun flaky SSHRemoteJobOperator kill test on process-group races test_kill_terminates_whole_job_tree intermittently fails its pre-kill check on CI: the wrapper records $! expecting it to equal the job PGID, but setsid only skips forking when the launching shell is not a process-group leader. On some runners it forks, so $! is the short-lived setsid parent and the job's real group is empty by the time pgrep -g runs. Rerun on a fresh draw so the environment-dependent race does not fail unrelated PRs. --- providers/ssh/tests/unit/ssh/utils/test_remote_job.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/providers/ssh/tests/unit/ssh/utils/test_remote_job.py b/providers/ssh/tests/unit/ssh/utils/test_remote_job.py index 4e7eca9b6973c..56fe5d7abb33a 100644 --- a/providers/ssh/tests/unit/ssh/utils/test_remote_job.py +++ b/providers/ssh/tests/unit/ssh/utils/test_remote_job.py @@ -271,6 +271,10 @@ def _group_alive(pgid: int) -> bool: # pgrep -g matches by process-group id; rc 0 => at least one member alive. return subprocess.run(["pgrep", "-g", str(pgid)], capture_output=True, check=False).returncode == 0 + # setsid only avoids forking when the launching shell is not a process-group leader; on some + # CI runners it forks, so the recorded $! is the short-lived setsid parent rather than the job + # PGID and the pre-kill pgrep -g finds an empty group. Re-launch on a fresh draw. + @pytest.mark.flaky(reruns=5) def test_kill_terminates_whole_job_tree(self, tmp_path): paths = RemoteJobPaths(job_id="killtree", remote_os="posix", base_dir=str(tmp_path / "jobs")) # `sleep 300` runs as a child of the wrapper subshell -> the tree the old kill orphaned.