clh: return faster with dead clh process from isClhRunning

Through proactively checking if Cloud Hypervisor process is dead,
this patch provides a faster path for isClhRunning

Fixes: #5623

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
This commit is contained in:
Alexandru Matei 2022-11-08 21:05:22 +02:00
parent 9ef68e0c7a
commit 0e3ac66e76

View File

@ -1405,16 +1405,16 @@ func (clh *cloudHypervisor) isClhRunning(timeout uint) (bool, error) {
return false, nil
}
if err := syscall.Kill(pid, syscall.Signal(0)); err != nil {
return false, nil
}
timeStart := time.Now()
cl := clh.client()
for {
err := syscall.Kill(pid, syscall.Signal(0))
if err != nil {
return false, nil
}
ctx, cancel := context.WithTimeout(context.Background(), clh.getClhAPITimeout()*time.Second)
defer cancel()
_, _, err := cl.VmmPingGet(ctx)
_, _, err = cl.VmmPingGet(ctx)
cancel()
if err == nil {
return true, nil
} else {