From: Michael Fritch Date: Fri, 10 Sep 2021 13:38:48 +0000 (-0600) Subject: cephadm: skip podman check during `rm-repo` X-Git-Tag: v16.2.7~67^2~69 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=da02cef488ab3dd3f33d7c66cdccd7d48b638e3b;p=ceph.git cephadm: skip podman check during `rm-repo` allow the `rm-repo` command to succeed when podman is not installed Signed-off-by: Michael Fritch (cherry picked from commit fd977773a57e12003fb02bdc762bf6bc89d785a1) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 33d90d6e3698..4d6e4ee4499d 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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) diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index d70ec82a3fe3..f65febcb84ad 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -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)