Skip to content

Commit

Permalink
Have lsf_driver specify SIGKILL when bkilling (#7433)
Browse files Browse the repository at this point in the history
Have lsf_driver specify SIGKILL signal when using bkill
  • Loading branch information
jonathan-eq authored Mar 21, 2024
1 parent 6fa9a13 commit a71a6df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/clib/lib/job_queue/lsf_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,15 +735,24 @@ void lsf_driver_kill_job(void *_driver, void *_job) {
char **argv = (char **)calloc(2, sizeof *argv);
CHECK_ALLOC(argv);
argv[0] = driver->remote_lsf_server;
argv[1] = saprintf("%s %s", driver->bkill_cmd, job->lsf_jobnr_char);
argv[1] = saprintf("%s %s %s", driver->bkill_cmd, "-s SIGKILL",
job->lsf_jobnr_char);

spawn_blocking(driver->rsh_cmd, 2, (const char **)argv, NULL, NULL);

free(argv[1]);
free(argv);
} else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) {
spawn_blocking(driver->bkill_cmd, 1,
(const char **)&job->lsf_jobnr_char, NULL, NULL);
char **argv = (char **)calloc(3, sizeof *argv);
CHECK_ALLOC(argv);
argv[0] = saprintf("%s", "-s");
argv[1] = saprintf("%s", "SIGKILL");
argv[2] = saprintf("%s", job->lsf_jobnr_char);
spawn_blocking(driver->bkill_cmd, 3, (const char **)argv, NULL, NULL);
free(argv[0]);
free(argv[1]);
free(argv[2]);
free(argv);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/ert/scheduler/lsf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ async def kill(self, iens: int) -> None:
logger.debug(f"Killing realization {iens} with LSF-id {job_id}")
process = await asyncio.create_subprocess_exec(
self._bkill_cmd,
"-s",
"SIGKILL",
job_id,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
Expand Down
8 changes: 3 additions & 5 deletions tests/unit_tests/scheduler/test_lsf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ async def test_faulty_bsub(monkeypatch, tmp_path, bsub_script, expectation):
await driver.submit(0, "sleep")


@pytest.mark.timeout(10)
@pytest.mark.parametrize(
"mocked_iens2jobid, iens_to_kill, bkill_returncode, bkill_stdout, bkill_stderr, expected_logged_error",
[
Expand Down Expand Up @@ -273,16 +274,13 @@ async def test_kill(
bkill_path.chmod(bkill_path.stat().st_mode | stat.S_IEXEC)

driver = LsfDriver()

driver._iens2jobid = mocked_iens2jobid
await driver.kill(iens_to_kill)
if expected_logged_error:
assert expected_logged_error in caplog.text
else:
assert (
mocked_iens2jobid[iens_to_kill]
== Path("bkill_args").read_text(encoding="utf-8").strip()
)
bkill_args = Path("bkill_args").read_text(encoding="utf-8").strip()
assert f"-s SIGKILL {mocked_iens2jobid[iens_to_kill]}" in bkill_args


@given(st.text())
Expand Down

0 comments on commit a71a6df

Please sign in to comment.