masterd: Shutdown only once running jobs have been processed
masterd: Shutdown only once running jobs have been processed

Until now, if masterd received a fatal signal, it would start shutting
down immediately. In the meantime it would hang while jobs are still
processed. Clients couldn't connect anymore to retrieve a jobs' status.

This this patch masterd checks if any job is running before shutting
down. If there is it'll check again every five seconds. Once all jobs
are finished, it waits another five seconds to give clients a chance to
retrieve the jobs' status. After that masterd will shutdown in a clean
fashion.

If a second signal is received the old behaviour is preserved.

Signed-off-by: Michael Hanselmann <68b67885ff74281219b4a4be33cc20fd45078d7c@google.com>
Reviewed-by: Iustin Pop <acf83a5274f31a43af6b914614365999469c1a31@google.com>

onponomarev/ganeti,mbakke/ganeti,grnet/snf-ganeti,yiannist/ganeti,apyrgio/ganeti,bitemyapp/ganeti,yiannist/ganeti,apyrgio/ganeti,ganeti-github-testing/ganeti-test-1,andir/ganeti,dimara/ganeti,bitemyapp/ganeti,yiannist/ganeti,onponomarev/ganeti,ganeti-github-testing/ganeti-test-1,leshchevds/ganeti,ganeti/ganeti,apyrgio/snf-ganeti,ganeti/ganeti,leshchevds/ganeti,leshchevds/ganeti,andir/ganeti,apyrgio/snf-ganeti,dimara/ganeti,ganeti/ganeti,mbakke/ganeti,andir/ganeti,grnet/snf-ganeti,mbakke/ganeti