Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix openstack_upgrade_available failing on unconventional source #705

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions charmhelpers/contrib/openstack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Comment on lines +852 to +853
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've spent a while staring at this, as it was going around my head, and I then realised that this is changing the nature of openstack_upgrade_availble() from the existing behaviour of erroring out (using error_out() in get_os_version_codename()) to a new behaviour of raising an exception (ValueError).

To fix this, this function (openstack_upgrade_avialble()) should also take an optional raise_exception=False parameter, and whatever calls it should pass in raise_exception=True to get the new behaviour. Otherwise, a whole load of charms may get different behaviour from what they are expecting currently.

except Exception:
avail_vers = cur_vers
apt.init()
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/openstack/test_openstack_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down