Przeglądaj źródła

Ignore Exceptions while uninstalling packages on SUSE.

Considering `zypper` does not have an `--ignore-missing`-type flag, and
returns a non-zero exit code when a package it's trying to uninstall is
missing, Coriolis will now silently skip any uninstallation issues on
SLES.
Nashwan Azhari 7 lat temu
rodzic
commit
81c9319124
1 zmienionych plików z 15 dodań i 2 usunięć
  1. 15 2
      coriolis/osmorphing/suse.py

+ 15 - 2
coriolis/osmorphing/suse.py

@@ -3,9 +3,15 @@
 
 import re
 
+from oslo_log import log as logging
+
+from coriolis import utils
 from coriolis.osmorphing import base
 
 
+LOG = logging.getLogger(__name__)
+
+
 class BaseSUSEMorphingTools(base.BaseLinuxOSMorphingTools):
     def _check_os(self):
         os_release = self._get_os_release()
@@ -59,5 +65,12 @@ class BaseSUSEMorphingTools(base.BaseLinuxOSMorphingTools):
             'zypper --non-interactive install %s' % " ".join(package_names))
 
     def uninstall_packages(self, package_names):
-        self._exec_cmd_chroot(
-            'zypper --non-interactive remove %s' % " ".join(package_names))
+        try:
+            self._exec_cmd_chroot(
+                'zypper --non-interactive remove %s' % " ".join(package_names))
+        except Exception:
+            self._event_manager.progress_update(
+                "Error occured while uninstalling packages. Ignoring")
+            LOG.warn(
+                "Error occured while uninstalling packages. Ignoring. "
+                "Exception:\n%s", utils.get_exception_details())