Ensure upgrade installs correct configs
When we do an openstack upgrade we must ensure that release version dependant decisions are made at the right time. In this patch we ensure that we choose configs after the target release packages have been installed so as to be sure that e.g. when upgrading from Newton to Ocata the apache2 wsgi conf is installed for the cinder-api. Change-Id: I9414940535406c7c7491636839a328df1ac9235b Closes-Bug: 1726527
This commit is contained in:
parent
6c731ad9fe
commit
c1653c2113
@ -30,7 +30,6 @@ from charmhelpers.core.hookenv import (
|
||||
|
||||
from cinder_hooks import (
|
||||
config_changed,
|
||||
CONFIGS,
|
||||
)
|
||||
|
||||
from cinder_utils import (
|
||||
@ -48,7 +47,7 @@ def openstack_upgrade():
|
||||
|
||||
if (do_action_openstack_upgrade('cinder-common',
|
||||
do_openstack_upgrade,
|
||||
CONFIGS)):
|
||||
configs=None)):
|
||||
# tell any storage-backends we just upgraded
|
||||
for rid in relation_ids('storage-backend'):
|
||||
relation_set(relation_id=rid,
|
||||
|
@ -733,7 +733,7 @@ def set_ceph_env_variables(service):
|
||||
out.write('env CEPH_ARGS="--id %s"\n' % service)
|
||||
|
||||
|
||||
def do_openstack_upgrade(configs):
|
||||
def do_openstack_upgrade(configs=None):
|
||||
"""Perform an uprade of cinder. Takes care of upgrading
|
||||
packages, rewriting configs + database migration and
|
||||
potentially any other post-upgrade actions.
|
||||
@ -756,6 +756,11 @@ def do_openstack_upgrade(configs):
|
||||
reset_os_release()
|
||||
apt_install(determine_packages(), fatal=True)
|
||||
|
||||
# NOTE(hopem): must do this after packages have been upgraded so that
|
||||
# we ensure that correct configs are selected for the target release.
|
||||
# See LP 1726527.
|
||||
configs = register_configs()
|
||||
|
||||
# set CONFIGS to load templates from new release and regenerate config
|
||||
configs.set_release(openstack_release=new_os_rel)
|
||||
configs.write_all()
|
||||
|
@ -732,10 +732,12 @@ class TestCinderUtils(CharmTestCase):
|
||||
out.write('env CEPH_ARGS="--id %s"\n' % service)
|
||||
"""
|
||||
|
||||
@patch.object(cinder_utils, 'register_configs')
|
||||
@patch.object(cinder_utils, 'services')
|
||||
@patch.object(cinder_utils, 'migrate_database')
|
||||
@patch.object(cinder_utils, 'determine_packages')
|
||||
def test_openstack_upgrade_leader(self, pkgs, migrate, services):
|
||||
def test_openstack_upgrade_leader(self, pkgs, migrate, services,
|
||||
mock_register_configs):
|
||||
pkgs.return_value = ['mypackage']
|
||||
self.os_release.return_value = 'havana'
|
||||
self.config.side_effect = None
|
||||
@ -743,8 +745,9 @@ class TestCinderUtils(CharmTestCase):
|
||||
services.return_value = ['cinder-api', 'cinder-volume']
|
||||
self.is_elected_leader.return_value = True
|
||||
self.get_os_codename_install_source.return_value = 'havana'
|
||||
configs = MagicMock()
|
||||
configs = mock_register_configs.return_value
|
||||
cinder_utils.do_openstack_upgrade(configs)
|
||||
self.assertTrue(mock_register_configs.called)
|
||||
self.assertTrue(configs.write_all.called)
|
||||
self.apt_upgrade.assert_called_with(options=DPKG_OPTIONS,
|
||||
fatal=True, dist=True)
|
||||
@ -752,10 +755,12 @@ class TestCinderUtils(CharmTestCase):
|
||||
configs.set_release.assert_called_with(openstack_release='havana')
|
||||
self.assertTrue(migrate.called)
|
||||
|
||||
@patch.object(cinder_utils, 'register_configs')
|
||||
@patch.object(cinder_utils, 'services')
|
||||
@patch.object(cinder_utils, 'migrate_database')
|
||||
@patch.object(cinder_utils, 'determine_packages')
|
||||
def test_openstack_upgrade_not_leader(self, pkgs, migrate, services):
|
||||
def test_openstack_upgrade_not_leader(self, pkgs, migrate, services,
|
||||
mock_register_configs):
|
||||
pkgs.return_value = ['mypackage']
|
||||
self.os_release.return_value = 'havana'
|
||||
self.config.side_effect = None
|
||||
@ -763,8 +768,9 @@ class TestCinderUtils(CharmTestCase):
|
||||
services.return_value = ['cinder-api', 'cinder-volume']
|
||||
self.is_elected_leader.return_value = False
|
||||
self.get_os_codename_install_source.return_value = 'havana'
|
||||
configs = MagicMock()
|
||||
configs = mock_register_configs.return_value
|
||||
cinder_utils.do_openstack_upgrade(configs)
|
||||
self.assertTrue(mock_register_configs.called)
|
||||
self.assertTrue(configs.write_all.called)
|
||||
self.apt_upgrade.assert_called_with(options=DPKG_OPTIONS,
|
||||
fatal=True, dist=True)
|
||||
|
Loading…
Reference in New Issue
Block a user