Fix minor openstack upgrade issues

Ensure that any new package requirements are installed for the
new OpenStack release version.

Reset os_release cache during the upgrade process to pickup the
new release.

Change-Id: Ied85f83ad4fabf1fb946df7db94aa4c847b4c075
Closes-Bug: 1715624
This commit is contained in:
James Page 2017-09-07 17:25:47 +01:00
parent 99108164c6
commit efda3b9ddf
2 changed files with 10 additions and 1 deletions

View File

@ -41,6 +41,7 @@ from charmhelpers.contrib.openstack.utils import (
is_unit_paused_set,
os_application_version_set,
CompareOpenStackReleases,
reset_os_release,
)
from charmhelpers.contrib.python.packages import (
pip_install,
@ -304,6 +305,8 @@ def do_openstack_upgrade(configs):
]
apt_update(fatal=True)
apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
reset_os_release()
apt_install(determine_packages(), fatal=True)
# set CONFIGS to load templates from new release
configs.set_release(openstack_release=new_os_rel)

View File

@ -28,11 +28,13 @@ TO_PATCH = [
'get_os_codename_install_source',
'apt_update',
'apt_upgrade',
'apt_install',
'configure_installation_source',
'log',
'cmp_pkgrevno',
'os_release',
'os_application_version_set',
'reset_os_release',
]
openstack_origin_git = \
@ -110,10 +112,12 @@ class TestHorizohorizon_utils(CharmTestCase):
])
self.assertEquals(horizon_utils.restart_map(), ex_map)
def test_do_openstack_upgrade(self):
@patch.object(horizon_utils, 'determine_packages')
def test_do_openstack_upgrade(self, determine_packages):
self.config.return_value = 'cloud:precise-havana'
self.get_os_codename_install_source.return_value = 'havana'
configs = MagicMock()
determine_packages.return_value = ['testpkg']
horizon_utils.do_openstack_upgrade(configs)
configs.set_release.assert_called_with(openstack_release='havana')
self.assertTrue(self.log.called)
@ -124,6 +128,8 @@ class TestHorizohorizon_utils(CharmTestCase):
]
self.apt_upgrade.assert_called_with(options=dpkg_opts,
dist=True, fatal=True)
self.apt_install.assert_called_with(['testpkg'], fatal=True)
self.reset_os_release.assert_called()
self.configure_installation_source.assert_called_with(
'cloud:precise-havana'
)