Răsfoiți Sursa

debian: skip updating initramfs if "linux-version" is missing

Container images such as the ones used by the integration tests
do not include the "linux-version" binary. We'll catch this
and log a warning.
Lucian Petrut 1 săptămână în urmă
părinte
comite
b2aee2409f
1 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 9 1
      coriolis/osmorphing/debian.py

+ 9 - 1
coriolis/osmorphing/debian.py

@@ -169,7 +169,15 @@ class BaseDebianMorphingTools(base.BaseLinuxOSMorphingTools):
         # Using 'env' rather than a shell assignment prefix because
         # Using 'env' rather than a shell assignment prefix because
         # _exec_cmd_chroot runs the command directly via chroot (no shell),
         # _exec_cmd_chroot runs the command directly via chroot (no shell),
         # so "LC_ALL=C cmd" would be treated as the binary name.
         # so "LC_ALL=C cmd" would be treated as the binary name.
-        raw = self._exec_cmd_chroot("env LC_ALL=C linux-version list")
+        try:
+            raw = self._exec_cmd_chroot("env LC_ALL=C linux-version list")
+        except exception.SSHCommandNotFoundException as ex:
+            # Container images such as the ones used by the integration tests
+            # do not include the "linux-version" binary.
+            LOG.warning(
+                "Unable to enumerate kernel versions, skipping "
+                "update-initramfs. Exception: %s", ex)
+            return
 
 
         kernel_versions = [v for v in raw.splitlines() if v and v[0].isdigit()]
         kernel_versions = [v for v in raw.splitlines() if v and v[0].isdigit()]
         if not kernel_versions:
         if not kernel_versions: