From 755a08e8faaf9e6b383bcfbc7011aa3bb25e8c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ksawery=20Dzieko=C5=84ski?= Date: Mon, 9 May 2022 12:34:38 +0200 Subject: [PATCH] Fix `openstack_upgrade_available` failing on unconventional source Related: LP#1965966 --- charmhelpers/contrib/openstack/utils.py | 7 ++++--- tests/contrib/openstack/test_openstack_utils.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/charmhelpers/contrib/openstack/utils.py b/charmhelpers/contrib/openstack/utils.py index 1d9f90730..f6be70f9b 100644 --- a/charmhelpers/contrib/openstack/utils.py +++ b/charmhelpers/contrib/openstack/utils.py @@ -386,9 +386,9 @@ def get_os_codename_install_source(src): return v -def get_os_version_install_source(src): +def get_os_version_install_source(src, raise_exception=False): codename = get_os_codename_install_source(src) - return get_os_version_codename(codename) + return get_os_version_codename(codename, raise_exception=raise_exception) def get_os_codename_version(vers): @@ -849,7 +849,8 @@ def openstack_upgrade_available(package): avail_vers = get_os_version_codename_swift(codename) else: try: - avail_vers = get_os_version_install_source(src) + avail_vers = get_os_version_install_source(src, + raise_exception=True) except Exception: avail_vers = cur_vers apt.init() diff --git a/tests/contrib/openstack/test_openstack_utils.py b/tests/contrib/openstack/test_openstack_utils.py index 014371198..0de846eaa 100644 --- a/tests/contrib/openstack/test_openstack_utils.py +++ b/tests/contrib/openstack/test_openstack_utils.py @@ -239,7 +239,7 @@ def test_os_codename_from_install_source(self, mocked_lsb): def test_os_version_from_install_source(self, codename, version): codename.return_value = 'grizzly' openstack.get_os_version_install_source('cloud:precise-grizzly') - version.assert_called_with('grizzly') + version.assert_called_with('grizzly', raise_exception=False) @patch('charmhelpers.contrib.openstack.utils.lsb_release') def test_os_codename_from_bad_install_source(self, mocked_lsb):