Don't bind to ipv4 if prefer-ipv6 is true

Following https://tracker.ceph.com/issues/52867 we need to tell the OSD
which address family to use via the ms_bind_ipv4/6 config flags.
I added them to the ceph.conf template and updated the config hook.
Launchpad: https://bugs.launchpad.net/charm-ceph-osd/+bug/2056337

Change-Id: Ifbd59c204a82109e2b71991078f59537f6db42d3
This commit is contained in:
Federico Bosi 2024-03-06 16:34:29 +01:00
parent ae6ee7f590
commit 557a5011e5
No known key found for this signature in database
GPG Key ID: F7B881CCF7085A75
3 changed files with 58 additions and 0 deletions

View File

@ -488,6 +488,8 @@ def get_ceph_context(upgrading=False):
cephcontext['bdev_discard'] = False cephcontext['bdev_discard'] = False
if config('prefer-ipv6'): if config('prefer-ipv6'):
cephcontext['ms_bind_ipv4'] = False
cephcontext['ms_bind_ipv6'] = True
dynamic_ipv6_address = get_ipv6_addr()[0] dynamic_ipv6_address = get_ipv6_addr()[0]
if not public_network: if not public_network:
cephcontext['public_addr'] = dynamic_ipv6_address cephcontext['public_addr'] = dynamic_ipv6_address

View File

@ -15,6 +15,12 @@ err to syslog = {{ use_syslog }}
clog to syslog = {{ use_syslog }} clog to syslog = {{ use_syslog }}
debug osd = {{ loglevel }}/5 debug osd = {{ loglevel }}/5
{% if ms_bind_ipv6 %}
ms_bind_ipv6 = true
{%- endif %}
{%- if ms_bind_ipv4 == false %}
ms_bind_ipv4 = false
{% endif %}
{% if ceph_public_network is string %} {% if ceph_public_network is string %}
public network = {{ ceph_public_network }} public network = {{ ceph_public_network }}
{%- endif %} {%- endif %}

View File

@ -431,6 +431,56 @@ class CephHooksTestCase(unittest.TestCase):
'fake-bluestore-compression-key': 'fake-value'} 'fake-bluestore-compression-key': 'fake-value'}
self.assertEqual(ctxt, expected) self.assertEqual(ctxt, expected)
@patch.object(ceph_hooks.ch_context, 'CephBlueStoreCompressionContext',
lambda: lambda: {})
@patch.object(ceph_hooks, 'get_mon_hosts',
lambda *args: ['2a01:348:2f4:0:685e:5748:ae62:209f',
'2a01:348:2f4:0:685e:5748:ae62:20a0'])
@patch.object(ceph_hooks, 'get_ipv6_addr',
lambda *args: ['2a01:348:2f4:0:685e:5748:ae62:209f'])
@patch.object(ceph_hooks.ch_ceph, 'get_osd_settings', lambda *args: {})
@patch.object(ceph_hooks, 'get_fsid', lambda *args: '1234')
@patch.object(ceph_hooks, 'get_auth', lambda *args: False)
@patch.object(ceph_hooks, 'cmp_pkgrevno', lambda *args: 1)
@patch.object(ceph_hooks, 'get_networks', lambda *args: "")
@patch.object(ceph, 'config')
@patch.object(ceph_hooks, 'config')
def test_ipv6_only_env_bindings(self, mock_config, mock_config2):
config = copy.deepcopy(CHARM_CONFIG)
config['prefer-ipv6'] = True
mock_config.side_effect = lambda key: config[key]
mock_config2.side_effect = lambda key: config[key]
ctxt = ceph_hooks.get_ceph_context()
expected = {
'auth_supported': False,
'ceph_cluster_network': '',
'ceph_public_network': '',
'dio': 'true',
'fsid': '1234',
'loglevel': 1,
'old_auth': False,
'crush_initial_weight': '0',
'osd_journal_size': 1024,
'osd_max_backfills': 1,
'osd_recovery_max_active': 2,
'osd_from_client': OrderedDict(),
'osd_from_client_conflict': OrderedDict(),
'short_object_len': True,
'upgrade_in_progress': False,
'use_syslog': 'true',
'bdev_discard': True,
'bluestore_experimental': False,
'bluestore_block_wal_size': 0,
'bluestore_block_db_size': 0,
'cluster_addr': '2a01:348:2f4:0:685e:5748:ae62:209f',
'public_addr': '2a01:348:2f4:0:685e:5748:ae62:209f',
'mon_hosts': '2a01:348:2f4:0:685e:5748:ae62:209f '
'2a01:348:2f4:0:685e:5748:ae62:20a0',
'ms_bind_ipv4': False,
'ms_bind_ipv6': True,
}
self.assertEqual(ctxt, expected)
@patch.object(ceph_hooks, 'ceph') @patch.object(ceph_hooks, 'ceph')
@patch.object(ceph_hooks, 'service_restart') @patch.object(ceph_hooks, 'service_restart')
@patch.object(ceph_hooks, 'service_reload') @patch.object(ceph_hooks, 'service_reload')