From 5fc333d0b6acdcacc3a8f788216ea33654c5ae9f Mon Sep 17 00:00:00 2001 From: Guilherme Gallo Date: Fri, 8 Apr 2022 11:52:50 -0300 Subject: [PATCH] ci/lava: Cancel the job if the script is interrupted During development, we may want to test lava_job_submitter.py locally, sometimes one can find what one is been looking for before the LAV job is done. Let's respond to SIGINT signal and cancel the LAVA job, as we can't follow what is happening anymore via script. Signed-off-by: Guilherme Gallo Part-of: --- .gitlab-ci/lava/lava_job_submitter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci/lava/lava_job_submitter.py b/.gitlab-ci/lava/lava_job_submitter.py index f840145c172..486fd1608da 100755 --- a/.gitlab-ci/lava/lava_job_submitter.py +++ b/.gitlab-ci/lava/lava_job_submitter.py @@ -395,6 +395,10 @@ def retriable_follow_job(proxy, job_definition): except MesaCIException as mesa_exception: print_log(mesa_exception) job.cancel() + except KeyboardInterrupt as e: + print_log("LAVA job submitter was interrupted. Cancelling the job.") + job.cancel() + raise e finally: print_log(f"Finished executing LAVA job in the attempt #{attempt_no}")