ソースを参照

Merge pull request #179 from Dany9966/minion-healthcheck-fix

Minion healthcheck fix and unmount all devs when looking for guest contents
Nashwan Azhari 5 年 前
コミット
145fdc0049
2 ファイル変更19 行追加20 行削除
  1. 18 19
      coriolis/osmorphing/osmount/base.py
  2. 1 1
      coriolis/providers/base.py

+ 18 - 19
coriolis/osmorphing/osmount/base.py

@@ -377,6 +377,21 @@ class BaseLinuxOSMountTools(BaseSSHOSMountTools):
                 # NOTE: it's possible that the device was mounted successfully
                 # but an I/O error occurs later along the line:
                 dirs = utils.list_ssh_dir(self._ssh, tmp_dir)
+                LOG.debug("Contents of device %s:\n%s", dev_path, dirs)
+
+                if all_files and dirs:
+                    common = [i if i in dirs else None for i in all_files]
+                    if not all(common):
+                        continue
+
+                    dev_name = dev_path
+                    break
+                elif one_of_files and dirs:
+                    common = [i for i in one_of_files if i in dirs]
+                    if len(common) > 0:
+                        dev_name = dev_path
+                        break
+
             except Exception:
                 self._event_manager.progress_update(
                     "Failed to mount and scan device '%s'" % dev_path)
@@ -389,27 +404,11 @@ class BaseLinuxOSMountTools(BaseSSHOSMountTools):
                 utils.ignore_exceptions(self._exec_cmd)(
                     "sudo rmdir %s" % tmp_dir
                 )
+                tmp_dir = None
                 continue
-
-            LOG.debug("Contents of device %s:\n%s", dev_path, dirs)
-
-            if all_files and dirs:
-                common = [i if i in dirs else None for i in all_files]
-                if not all(common):
+            finally:
+                if tmp_dir:
                     self._exec_cmd('sudo umount %s' % tmp_dir)
-                    continue
-
-                dev_name = dev_path
-                self._exec_cmd('sudo umount %s' % tmp_dir)
-            elif one_of_files and dirs:
-                common = [i for i in one_of_files if i in dirs]
-                if len(common) > 0:
-                    dev_name = dev_path
-                    self._exec_cmd('sudo umount %s' % tmp_dir)
-                    break
-            else:
-                self._exec_cmd('sudo umount %s' % tmp_dir)
-                continue
 
         return dev_name
 

+ 1 - 1
coriolis/providers/base.py

@@ -616,7 +616,7 @@ class _BaseMinionPoolProvider(
 
     @abc.abstractmethod
     def healthcheck_minion(
-            self, ctxt, environment_options, connection_info,
+            self, ctxt, connection_info,
             minion_properties, minion_connection_info):
         pass