-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Implement force-kill option in verdi process kill #6575
base: main
Are you sure you want to change the base?
Conversation
This allows plumpy ignore the callback so it does not get stuck in it but directly transitions the process to killed. The disadvantage is that the job behind the process might not be killed as we do not wait for. But I think that can be clearly communicated to the user in the help message and it has a similar logic as `kill -9 <PID>`. TODO: As you mentioned @kh with this solution the worker process will not be killed. Some parts of plumpy in stepping are needed to kill the process, but I am not sure which ones.
for more information, see https://pre-commit.ci
Thanks @agoscinski
and says:
|
This part is key. If you want to kill a The question is what the code should do in this case. Maybe the EBM should be disabled when calling the scheduler's kill command. But then again, what if the |
Yes, exactly! I was thinking about this as well. Once done, this PR should address all possibilities:
|
2af67e7
to
8e080b0
Compare
8e080b0
to
75bb430
Compare
Don't worry about tests failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @agoscinski some initial comments/suggestions
raise | ||
except Exception as exception: | ||
logger.warning(f'killing CalcJob<{node.pk}> failed') | ||
logger.warning(f'killing CalcJob<{node.pk}> excepted, the job might be orphaned.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this warning is correct. When a TransportTaskException
is raised, the Waiting.execute
method catches it and pauses the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong, what you are referring to is already in my test scenario
(see here test_process.py::test_process_kill
# 10)
And is being passed, meaning the job is being EXCEPTED
, not paused..
(maybe there is a bug somewhere else?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. The exception being caught here is thrown by do_kill
so it is the kill operation (i.e. getting the transport or using it to call the kill command of the scheduler) that excepted, not the process itself. The exception is then reraised as a TransportTaskException
which is caught in Waiting.execute
and rethrown as PauseInterruption
on line 571, which means the process is going into pause. So how does this mean the process is already excepted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
Just added one more test, and I'm now explicitly patching and returning TransportTaskException
from task_kill_job
.
We still receive EXCEPTED
regardless of whether the process was running normally or was stuck in EBM.
Haven't figured out why yet.
This allows plumpy ignore the callback so it does not get stuck in it but directly transitions the process to killed. The disadvantage is that the job behind the process might not be killed as we do not wait for. But I think that can be clearly communicated to the user in the help message and it has a similar logic as
kill -9 <PID>
.This PR goes together with the PR in plumpy aiidateam/plumpy#288
TODO:
As you feared @khsrali with this solution the worker process will not be killed, so the upload async function still continues, so maybe we still need to find a solution that actually sends the message back to aiida-core. It is really weird, I feel like
_stepping
part in plumpy is buggy, because it only the transition function actually returns back to the sender of the message (whereverdi process kill <PID>
was sent), while only call the callback docalcjobs.tasks.task_kill_job
in the _stepping part kills the process occupying the worker (when removing the exponential backof from the kill), but it should do both. I have this a bug on my system also when just killing local jobs that sleep. Maybe we can check on your machine.Co-author @khsrali