Change in vdsm[master]: recovery: try to restore VMs from recovery files

fromani at redhat.com fromani at redhat.com
Mon Mar 3 14:09:05 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: recovery: try to restore VMs from recovery files
......................................................................

recovery: try to restore VMs from recovery files

on recovery, VDSM tries to recover the all the VMs reported
as active by libvirt.
If a VM disappears while VDSM is down or restarting, the
VM silently disappears without VDSM noticing, and the recovery
file is discarded.

This patch adds a second recovery try for the VMs which have
a recovery file but not yet restored using the standard recovry
loop.

Those VMs are most down on the recovering host, but VDSM has
to notify the engine so it is can do proper cleanup and it can
ensure the correct state is reported to users.

This patch depends on
I00ef12883c8035209de0f273925eb8603d6b6da8
which make sure VMs are setup and reported correctly if
the underlying QEMU process disappeared.

Change-Id: Id495f6047ba658c2b04da19bd7bf76425b3b9659
Bug-Url: https://bugzilla.redhat.com/1045626
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/clientIF.py
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/25276/1

diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index f8fe499..de3b648 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -19,6 +19,7 @@
 #
 
 import os
+import os.path
 import time
 import threading
 import pickle
@@ -415,6 +416,13 @@
                                        'process with id: %s',
                                        vmId, exc_info=True)
 
+            # we do this to safely handle VMs which disappeared
+            # from the host while VDSM was down/restarting
+            for vmId in self._getVDSMVmsFromRecovery():
+                if not self._recoverVm(vmId):
+                    self.log.info('expected VM %s from recovery file but'
+                                  'missing, reported as Down', vmId)
+
             while (self._enabled and
                    'WaitForLaunch' in [v.lastStatus for v in
                                        self.vmContainer.values()]):
@@ -492,6 +500,17 @@
                 vms.append(vm)
         return [vm for vm in vms if self.isVDSMVm(vm)]
 
+    def _getVDSMVmsFromRecovery(self):
+        vms = []
+        for f in os.listdir(constants.P_VDSM_RUN):
+            vmId, fileType = os.path.splitext(f)
+            if fileType == ".recovery":
+                if vmId in self.vmContainer:
+                    self.log.info('vm %s already recovered', vmId)
+                else:
+                    vms.append(vmId)
+        return vms
+
     def _recoverVm(self, vmid):
         try:
             recoveryFile = constants.P_VDSM_RUN + vmid + ".recovery"


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id495f6047ba658c2b04da19bd7bf76425b3b9659
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list