Merge "Notify ceph-mon relations on version upgrade."
This commit is contained in:
commit
65a4f9df36
@ -153,6 +153,7 @@ def check_for_upgrade():
|
||||
ceph.roll_osd_cluster(new_version=new_version,
|
||||
upgrade_key='osd-upgrade')
|
||||
emit_cephconf(upgrading=False)
|
||||
notify_mon_of_upgrade(new_version)
|
||||
elif (old_version == new_version and
|
||||
old_version_os < new_version_os):
|
||||
# See LP: #1778823
|
||||
@ -170,6 +171,14 @@ def check_for_upgrade():
|
||||
level=ERROR)
|
||||
|
||||
|
||||
def notify_mon_of_upgrade(release):
|
||||
for relation_id in relation_ids('mon'):
|
||||
log('Notifying relation {} of upgrade to {}'.format(
|
||||
relation_id, release))
|
||||
relation_set(relation_id=relation_id,
|
||||
relation_settings=dict(ceph_release=release))
|
||||
|
||||
|
||||
def tune_network_adapters():
|
||||
interfaces = netifaces.interfaces()
|
||||
for interface in interfaces:
|
||||
@ -540,7 +549,10 @@ def prepare_disks_and_activate():
|
||||
relation_set(
|
||||
relation_id=r_id,
|
||||
relation_settings={
|
||||
'bootstrapped-osds': len(db.get('osd-devices', []))
|
||||
'bootstrapped-osds': len(db.get('osd-devices', [])),
|
||||
'ceph_release': ceph.resolve_ceph_version(
|
||||
hookenv.config('source') or 'distro'
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from mock import call, patch
|
||||
from test_utils import CharmTestCase
|
||||
from ceph_hooks import check_for_upgrade
|
||||
from ceph_hooks import check_for_upgrade, notify_mon_of_upgrade
|
||||
|
||||
|
||||
__author__ = 'Chris Holcombe <chris.holcombe@canonical.com>'
|
||||
@ -8,6 +8,7 @@ __author__ = 'Chris Holcombe <chris.holcombe@canonical.com>'
|
||||
|
||||
class UpgradeRollingTestCase(CharmTestCase):
|
||||
|
||||
@patch('ceph_hooks.notify_mon_of_upgrade')
|
||||
@patch('ceph_hooks.ceph.dirs_need_ownership_update')
|
||||
@patch('ceph_hooks.os.path.exists')
|
||||
@patch('ceph_hooks.ceph.resolve_ceph_version')
|
||||
@ -16,10 +17,13 @@ class UpgradeRollingTestCase(CharmTestCase):
|
||||
@patch('ceph_hooks.ceph.roll_osd_cluster')
|
||||
def test_check_for_upgrade(self, roll_osd_cluster, hookenv,
|
||||
emit_cephconf, version, exists,
|
||||
dirs_need_ownership_update):
|
||||
dirs_need_ownership_update,
|
||||
notify_mon_of_upgrade):
|
||||
dirs_need_ownership_update.return_value = False
|
||||
exists.return_value = True
|
||||
version.side_effect = ['firefly', 'hammer']
|
||||
version_pre = 'firefly'
|
||||
version_post = 'hammer'
|
||||
version.side_effect = [version_pre, version_post]
|
||||
|
||||
self.test_config.set_previous('source', "cloud:trusty-juno")
|
||||
self.test_config.set('source', 'cloud:trusty-kilo')
|
||||
@ -34,7 +38,9 @@ class UpgradeRollingTestCase(CharmTestCase):
|
||||
call(upgrading=False)])
|
||||
exists.assert_called_with(
|
||||
"/var/lib/ceph/osd/ceph.client.osd-upgrade.keyring")
|
||||
notify_mon_of_upgrade.assert_called_once_with(version_post)
|
||||
|
||||
@patch('ceph_hooks.notify_mon_of_upgrade')
|
||||
@patch('ceph_hooks.ceph.dirs_need_ownership_update')
|
||||
@patch('ceph_hooks.os.path.exists')
|
||||
@patch('ceph_hooks.ceph.resolve_ceph_version')
|
||||
@ -44,10 +50,12 @@ class UpgradeRollingTestCase(CharmTestCase):
|
||||
def test_resume_failed_upgrade(self, roll_osd_cluster,
|
||||
hookenv, emit_cephconf, version,
|
||||
exists,
|
||||
dirs_need_ownership_update):
|
||||
dirs_need_ownership_update,
|
||||
notify_mon_of_upgrade):
|
||||
dirs_need_ownership_update.return_value = True
|
||||
exists.return_value = True
|
||||
version.side_effect = ['jewel', 'jewel']
|
||||
version_pre_and_post = 'jewel'
|
||||
version.side_effect = [version_pre_and_post, version_pre_and_post]
|
||||
|
||||
check_for_upgrade()
|
||||
|
||||
@ -57,6 +65,7 @@ class UpgradeRollingTestCase(CharmTestCase):
|
||||
call(upgrading=False)])
|
||||
exists.assert_called_with(
|
||||
"/var/lib/ceph/osd/ceph.client.osd-upgrade.keyring")
|
||||
notify_mon_of_upgrade.assert_called_once_with(version_pre_and_post)
|
||||
|
||||
@patch('ceph_hooks.os.path.exists')
|
||||
@patch('ceph_hooks.ceph.resolve_ceph_version')
|
||||
@ -122,3 +131,28 @@ class UpgradeRollingTestCase(CharmTestCase):
|
||||
check_for_upgrade()
|
||||
roll_monitor_cluster.assert_not_called()
|
||||
add_source.assert_called_with('cloud:bionic-stein', 'some-key')
|
||||
|
||||
|
||||
class UpgradeUtilTestCase(CharmTestCase):
|
||||
@patch('ceph_hooks.relation_ids')
|
||||
@patch('ceph_hooks.log')
|
||||
@patch('ceph_hooks.relation_set')
|
||||
def test_notify_mon_of_upgrade(self, relation_set, log, relation_ids):
|
||||
relation_ids_to_check = ['1', '2', '3']
|
||||
relation_ids.return_value = relation_ids_to_check
|
||||
release = 'luminous'
|
||||
|
||||
notify_mon_of_upgrade(release)
|
||||
|
||||
self.assertEqual(log.call_count, len(relation_ids_to_check))
|
||||
relation_ids.assert_called_once_with('mon')
|
||||
set_dict = dict(ceph_release=release)
|
||||
relation_set_calls = [
|
||||
call(relation_id=relation_ids_to_check[0],
|
||||
relation_settings=set_dict),
|
||||
call(relation_id=relation_ids_to_check[1],
|
||||
relation_settings=set_dict),
|
||||
call(relation_id=relation_ids_to_check[2],
|
||||
relation_settings=set_dict),
|
||||
]
|
||||
relation_set.assert_has_calls(relation_set_calls)
|
||||
|
Loading…
Reference in New Issue
Block a user