Skip to content

Commit d945ded

Browse files
committed
Properly cleanup (build) jobs on abort
1 parent f51058c commit d945ded

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

reframe/core/pipeline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,12 +1762,14 @@ def _create_job(self, job_type, force_local=False, **job_opts):
17621762

17631763
if job_type == 'build':
17641764
script_name = 'rfm_build.sh'
1765+
job_name = f'rfm_build_{self.short_name}'
17651766
elif job_type == 'run':
17661767
script_name = 'rfm_job.sh'
1768+
job_name = f'rfm_{self.short_name}'
17671769

17681770
return Job.create(scheduler,
17691771
launcher,
1770-
name=f'rfm_{self.short_name}',
1772+
name=job_name,
17711773
script_filename=script_name,
17721774
workdir=self._stagedir,
17731775
sched_access=self._current_partition.access,

reframe/frontend/executors/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ def __exit__(this, exc_type, exc_value, traceback):
384384
# This practically ignores skipping during the cleanup phase
385385
self.skip()
386386
raise TaskExit from e
387-
except ABORT_REASONS:
388-
self.fail()
387+
except ABORT_REASONS as e:
388+
self.abort(e)
389389
raise
390390
except BaseException as e:
391391
self.fail()
@@ -516,6 +516,11 @@ def skip(self, exc_info=None):
516516
self._notify_listeners('on_task_skip')
517517

518518
def abort(self, cause=None):
519+
def _cancel_job(job):
520+
if job:
521+
with contextlib.suppress(JobNotStartedError):
522+
job.cancel()
523+
519524
if self.failed or self._aborted:
520525
return
521526

@@ -524,11 +529,8 @@ def abort(self, cause=None):
524529
exc.__cause__ = cause
525530
self._aborted = True
526531
try:
527-
if self.check.job:
528-
self.check.job.cancel()
529-
self.check.job.wait()
530-
except JobNotStartedError:
531-
self.fail((type(exc), exc, None), 'on_task_abort')
532+
_cancel_job(self.check.build_job)
533+
_cancel_job(self.check.job)
532534
except BaseException:
533535
self.fail()
534536
else:

unittests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def test_check_kbd_interrupt(run_reframe):
303303
)
304304
assert 'Traceback' not in stdout
305305
assert 'Traceback' not in stderr
306-
assert 'FAILED' in stdout
306+
assert 'ABORTED' in stdout
307307
assert returncode != 0
308308

309309

unittests/test_policies.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def test_kbd_interrupt_within_test(make_runner, make_cases, common_exec_ctx):
253253
runner.runall(make_cases([make_kbd_check()]))
254254

255255
stats = runner.stats
256-
assert 1 == len(stats.failed())
256+
assert 1 == len(stats.aborted())
257257
assert_all_dead(runner)
258258

259259

@@ -318,7 +318,7 @@ def test_sigterm_handling(make_runner, make_cases, common_exec_ctx):
318318

319319
assert_all_dead(runner)
320320
assert runner.stats.num_cases() == 1
321-
assert len(runner.stats.failed()) == 1
321+
assert len(runner.stats.aborted()) == 1
322322

323323

324324
def test_reruns(make_runner, make_cases, common_exec_ctx):
@@ -576,16 +576,13 @@ def test_concurrency_none(make_async_runner, make_cases,
576576
def assert_interrupted_run(runner):
577577
assert 4 == runner.stats.num_cases()
578578
assert_runall(runner)
579-
assert 1 == len(runner.stats.failed())
580-
assert 3 == len(runner.stats.aborted())
579+
assert 4 == len(runner.stats.aborted())
581580
assert_all_dead(runner)
582581

583582
# Verify that failure reasons for the different tasks are correct
584583
for t in runner.stats.tasks():
585-
if isinstance(t.check, KeyboardInterruptCheck):
586-
assert t.exc_info[0] == KeyboardInterrupt
587-
else:
588-
assert t.exc_info[0] == AbortTaskError
584+
assert t.exc_info[0] == AbortTaskError
585+
assert isinstance(t.exc_info[1].__cause__, KeyboardInterrupt)
589586

590587

591588
def test_kbd_interrupt_in_wait_with_concurrency(

0 commit comments

Comments
 (0)