daemon: graceful pid handling
Add the "killpath" api to set a program/script for
"killing" a pid/connection, where killing could
be anything that either causes the pid to exit,
or causes the pid to be put into a safe state and
releases its leases, e.g. pausing a vm.
Add a helper process to fork/exec the killpaths.
If pids need to be killed, a configured killpath will
first be run instead of kill(SIGTERM). If the pid
has not exited or had its leases released before
the existing SIGTERM time limit, then sanlock will
escalate to SIGKILL.
This allows for the following:
- pids running with leases in lockspace
- lockspace storage fails (i/o errors, host_id cannot be renewed)
- sanlock runs killpath for each pid
- killpath does inquire, saves state, releases leases
- sanlock finds no more pids with leases in lockspace
- sanlock releases lockspace
- pids remain, but without leases
later:
- lockspace storage is restored
- add_lockspace reacquires host_id
- leases are reacquired for each pid using saved state
- pids running with leases again
This sequence is used by the following test:
cd tests
cp killpath /root/killpath_pause
On host_id 1
./clientn 2 init /dev/bull/leases
./clientn 2 start /dev/bull/leases 1 /root/killpath_pause
./clientn 2 error /dev/bull/leases
./clientn 2 resume /dev/bull/leases 1
If between error and resume, host_id 2 completes:
./clientn 2 start /dev/bull/leases 2 /root/killpath_pause
Then, the resume on host_id 1 will fail and the sanlk_client
pids will be killed.
Python changes from:
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>