]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: skip podman check during `rm-repo`
authorMichael Fritch <mfritch@suse.com>
Fri, 10 Sep 2021 13:38:48 +0000 (07:38 -0600)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 2 Nov 2021 09:01:17 +0000 (10:01 +0100)
allow the `rm-repo` command to succeed when podman is not installed

Signed-off-by: Michael Fritch <mfritch@suse.com>
(cherry picked from commit fd977773a57e12003fb02bdc762bf6bc89d785a1)

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 33d90d6e36984f9fc7c437dc0a438313d8e7504c..4d6e4ee4499d51cd50beb56bfb0792807fbb8d8a 100755 (executable)
@@ -8466,7 +8466,13 @@ def main() -> None:
         # podman or docker?
         ctx.container_engine = find_container_engine(ctx)
         if ctx.func not in \
-                [command_check_host, command_prepare_host, command_add_repo, command_install]:
+                [
+                    command_check_host,
+                    command_prepare_host,
+                    command_add_repo,
+                    command_rm_repo,
+                    command_install
+                ]:
             check_container_engine(ctx)
         # command handler
         r = ctx.func(ctx)
index d70ec82a3fe31b319436fdf2e202cf76fe16a281..f65febcb84ad7a48bf09c6615d982bbaf56be18a 100644 (file)
@@ -12,6 +12,7 @@ import threading
 import unittest
 
 from http.server import HTTPServer
+from textwrap import dedent
 from urllib.request import Request, urlopen
 from urllib.error import HTTPError
 
@@ -1464,11 +1465,9 @@ class TestCheckHost:
 
     @mock.patch('cephadm.find_executable', return_value='foo')
     def test_container_engine(self, find_executable):
-        cmd = ['check-host']
-
         ctx = cd.CephadmContext()
-        ctx.container_engine = None
 
+        ctx.container_engine = None
         err = r'No container engine binary found'
         with pytest.raises(cd.Error, match=err):
             cd.command_check_host(ctx)
@@ -1478,3 +1477,74 @@ class TestCheckHost:
 
         ctx.container_engine = mock_docker()
         cd.command_check_host(ctx)
+
+
+class TestRmRepo:
+
+    @pytest.mark.parametrize('os_release',
+        [
+            # Apt
+            dedent("""
+            NAME="Ubuntu"
+            VERSION="20.04 LTS (Focal Fossa)"
+            ID=ubuntu
+            ID_LIKE=debian
+            PRETTY_NAME="Ubuntu 20.04 LTS"
+            VERSION_ID="20.04"
+            HOME_URL="https://www.ubuntu.com/"
+            SUPPORT_URL="https://help.ubuntu.com/"
+            BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
+            PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
+            VERSION_CODENAME=focal
+            UBUNTU_CODENAME=focal
+            """),
+
+            # YumDnf
+            dedent("""
+            NAME="CentOS Linux"
+            VERSION="8 (Core)"
+            ID="centos"
+            ID_LIKE="rhel fedora"
+            VERSION_ID="8"
+            PLATFORM_ID="platform:el8"
+            PRETTY_NAME="CentOS Linux 8 (Core)"
+            ANSI_COLOR="0;31"
+            CPE_NAME="cpe:/o:centos:centos:8"
+            HOME_URL="https://www.centos.org/"
+            BUG_REPORT_URL="https://bugs.centos.org/"
+
+            CENTOS_MANTISBT_PROJECT="CentOS-8"
+            CENTOS_MANTISBT_PROJECT_VERSION="8"
+            REDHAT_SUPPORT_PRODUCT="centos"
+            REDHAT_SUPPORT_PRODUCT_VERSION="8"
+            """),
+
+            # Zypper
+            dedent("""
+            NAME="openSUSE Tumbleweed"
+            # VERSION="20210810"
+            ID="opensuse-tumbleweed"
+            ID_LIKE="opensuse suse"
+            VERSION_ID="20210810"
+            PRETTY_NAME="openSUSE Tumbleweed"
+            ANSI_COLOR="0;32"
+            CPE_NAME="cpe:/o:opensuse:tumbleweed:20210810"
+            BUG_REPORT_URL="https://bugs.opensuse.org"
+            HOME_URL="https://www.opensuse.org/"
+            DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
+            LOGO="distributor-logo"
+            """),
+        ])
+    @mock.patch('cephadm.find_executable', return_value='foo')
+    def test_container_engine(self, find_executable, os_release, cephadm_fs):
+        cephadm_fs.create_file('/etc/os-release', contents=os_release)
+        ctx = cd.CephadmContext()
+
+        ctx.container_engine = None
+        cd.command_rm_repo(ctx)
+
+        ctx.container_engine = mock_podman()
+        cd.command_rm_repo(ctx)
+
+        ctx.container_engine = mock_docker()
+        cd.command_rm_repo(ctx)