Shahar Havivi has uploaded a new change for review.

Change subject: v2v: make sure not virt-v2v processes leftovers
......................................................................

v2v: make sure not virt-v2v processes leftovers

In case of vdsm restart/crash or in case of virt-v2v is hanging on an IO
wait we want to eliminate the remaining virt-v2v processes.

Added check on startup and on clearing v2v jobs.

Change-Id: I4788fdc57bae4047b2f83bcb56b790df58c46814
Signed-off-by: Shahar Havivi <[email protected]>
---
M vdsm/clientIF.py
M vdsm/v2v.py
2 files changed, 37 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/37938/1

diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index d29f8c2..37d6593 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -39,6 +39,7 @@
 import caps
 import blkid
 import supervdsm
+import v2v
 from protocoldetector import MultiProtocolAcceptor
 
 from virt import migration
@@ -112,6 +113,7 @@
             self._createAcceptor(host, port)
             self._prepareXMLRPCBinding()
             self._prepareJSONRPCBinding()
+            v2v.kill_zombie_jobs()
         except:
             self.log.error('failed to init clientIF, '
                            'shutting down storage dispatcher')
diff --git a/vdsm/v2v.py b/vdsm/v2v.py
index e169686..b6f6539 100644
--- a/vdsm/v2v.py
+++ b/vdsm/v2v.py
@@ -114,9 +114,44 @@
             logging.error('error reading file "%s" error: %r message %r',
                           file_name, exc.errno, exc.message)
             raise
+    else:
+        with _lock:
+            del _jobs[jobId]
+            if _jobs:
+                kill_zombie_jobs()
     return {'status': doneCode, 'ovf': ovf}
 
 
+def kill_zombie_jobs():
+    '''
+    make sure that we don't have virt-v2v jobs that vdsm doesn't know about.
+    this can be due to crash/restarting vdsm service or a general io blocking
+    problem in virt-v2v.
+    we are calling this method on vdsm startup and re-checking on removing
+    a job if there are no more jobs.
+    note that there should be no virt-v2v running task that vdsm is not
+    aware of.
+    '''
+    ret, out, err = execCmd([EXT_PGREP, 'virt-v2v'], sudo=True)
+    if len(err) > 0:
+        logging.error('error while trying to grep virt-v2v processes: %r', err)
+        return
+
+    for pid in out:
+        ret, out, err = execCmd([EXT_KILL, '-9', pid], sudo=True)
+        if len(err) > 0:
+            logging.error('error while trying to kill virt-v2v process %r: %r',
+                          pid, err)
+
+    ret, out, err = execCmd([EXT_PGREP, 'virt-v2v'], sudo=True)
+    if len(err) > 0:
+        logging.error('error while trying to grep virt-v2v'
+                      ' processes (second time): %r', err)
+        return
+    if len(out) > 0:
+        logging.error('cannot kill the following virt-v2v processes: %r', out)
+
+
 def abort_job(jobId):
     global _jobs
     with _lock:


-- 
To view, visit http://gerrit.ovirt.org/37938
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4788fdc57bae4047b2f83bcb56b790df58c46814
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to