Explicitly enable msgr2 for Nautilus and later

When updating to Ceph Nautilus (OpenStack Train) or later releases from
a pre-Nautilus release, msgr2 will not be enabled without manual
intervention (e.g. running `juju ssh ceph-mon/leader 'sudo ceph mon
enable-msgr2'`).

Leaving msgr2 disabled (i.e. using msgr1 only) isn't an issue for normal
operations; Ceph will simply show a warning in `sudo ceph status` that
this is the case. However, Ceph Nautilus and later releases default to
msgr2, meaning that new ceph-mon units will attempt to communicate with
the existing cluster using msgr2.

This commit enables msgr2 on package upgrades on all Ceph releases
including and after Nautilus.

Closes-Bug: #1840701
Change-Id: Ib90cd03b16f2062fa6c6a43d242d51306ae8ca95
This commit is contained in:
James Vaughn 2021-12-05 13:07:53 +00:00 committed by Chris MacNaughton
parent 328aa0f051
commit ff752de0f0
2 changed files with 40 additions and 4 deletions

View File

@ -2192,6 +2192,20 @@ def roll_monitor_cluster(new_version, upgrade_key):
wait_for_all_monitors_to_upgrade(new_version=new_version,
upgrade_key=upgrade_key)
bootstrap_manager()
# NOTE(jmcvaughn):
# Nautilus and later binaries use msgr2 by default, but existing
# clusters that have been upgraded from pre-Nautilus will not
# automatically have msgr2 enabled. Without this, Ceph will show
# a warning only (with no impact to operations), but newly added units
# will not be able to join the cluster. Therefore, we ensure it is
# enabled on upgrade for all versions including and after Nautilus
# (to cater for previous charm versions that will not have done this).
nautilus_or_later = cmp_pkgrevno('ceph-common', '14.0.0') >= 0
if nautilus_or_later:
wait_for_all_monitors_to_upgrade(new_version=new_version,
upgrade_key=upgrade_key)
enable_msgr2()
except ValueError:
log("Failed to find {} in list {}.".format(
my_name, mon_sorted_list))
@ -3338,6 +3352,16 @@ def bootstrap_manager():
service_restart(unit)
def enable_msgr2():
"""
Enables msgr2
:raises: subprocess.CalledProcessError if the command fails
"""
cmd = ['ceph', 'mon', 'enable-msgr2']
subprocess.check_call(cmd)
def osd_noout(enable):
"""Sets or unsets 'noout'

View File

@ -299,12 +299,13 @@ class UpgradeRollingTestCase(unittest.TestCase):
service='mon',
upgrade_key='admin',
version=new_version)
if new_version == 'luminous':
if new_version in ['luminous', 'mimic']:
wait_for_all_monitors_to_upgrade.assert_called_with(
new_version=new_version,
upgrade_key='admin',
)
bootstrap_manager.assert_called_once_with()
if new_version == 'luminous':
bootstrap_manager.assert_called_once_with()
else:
wait_for_all_monitors_to_upgrade.assert_not_called()
bootstrap_manager.assert_not_called()
@ -312,12 +313,23 @@ class UpgradeRollingTestCase(unittest.TestCase):
upgrade_monitor.assert_has_calls([
call(new_version, restart_daemons=False)])
def test_roll_monitor_cluster_luminous(self):
self._test_roll_monitor_cluster(new_version='luminous')
@patch.object(charms_ceph.utils, 'cmp_pkgrevno', lambda _x, _y: 1)
@patch.object(charms_ceph.utils, 'enable_msgr2')
def test_roll_monitor_cluster_mimic(self, mock_enable_msgr2):
self._test_roll_monitor_cluster(new_version='mimic')
mock_enable_msgr2.assert_called_once()
@patch.object(charms_ceph.utils, 'cmp_pkgrevno', lambda _x, _y: 1)
@patch.object(charms_ceph.utils, 'enable_msgr2')
def test_roll_monitor_cluster_luminous(self, mock_enable_msgr2):
self._test_roll_monitor_cluster(new_version='luminous')
mock_enable_msgr2.assert_called_once()
@patch.object(charms_ceph.utils, 'cmp_pkgrevno', lambda _x, _y: -1)
def test_roll_monitor_cluster_jewel(self):
self._test_roll_monitor_cluster(new_version='jewel')
@patch.object(charms_ceph.utils, 'cmp_pkgrevno', lambda _x, _y: -1)
def test_roll_monitor_cluster_hammer(self):
self._test_roll_monitor_cluster(new_version='hammer')