From ff752de0f06d8a06a4da722211931905fd4a827f Mon Sep 17 00:00:00 2001 From: James Vaughn Date: Sun, 5 Dec 2021 13:07:53 +0000 Subject: [PATCH] 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 --- charms_ceph/utils.py | 24 ++++++++++++++++++++++++ unit_tests/test_mon_upgrade_roll.py | 20 ++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/charms_ceph/utils.py b/charms_ceph/utils.py index 025ab86..6fea2d5 100644 --- a/charms_ceph/utils.py +++ b/charms_ceph/utils.py @@ -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' diff --git a/unit_tests/test_mon_upgrade_roll.py b/unit_tests/test_mon_upgrade_roll.py index 23ced4e..4bad3bd 100644 --- a/unit_tests/test_mon_upgrade_roll.py +++ b/unit_tests/test_mon_upgrade_roll.py @@ -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')