Skip to content

Commit

Permalink
Merge "Add ipv6 bind flags" into stable/quincy.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed May 6, 2024
2 parents 75ac3ad + 6d3c847 commit 07af099
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ceph-mon/src/ceph_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def get_ceph_context():

if config('prefer-ipv6'):
dynamic_ipv6_address = get_ipv6_addr()[0]
cephcontext['ms_bind_ipv4'] = False
cephcontext['ms_bind_ipv6'] = True
if not public_network:
cephcontext['public_addr'] = dynamic_ipv6_address
if not cluster_network:
Expand Down
6 changes: 6 additions & 0 deletions ceph-mon/templates/ceph.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ debug osd = {{ loglevel }}/5
# skew calculation.
mon pg warn max object skew = -1

{% 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 %}
public network = {{ ceph_public_network }}
{%- endif %}
Expand Down
36 changes: 36 additions & 0 deletions ceph-mon/unit_tests/test_ceph_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,42 @@ def test_get_ceph_context_w_config_flags_invalid(self, mock_config,
'use_syslog': 'true'}
self.assertEqual(ctxt, expected)

@patch.object(ceph_hooks, 'get_rbd_features', return_value=None)
@patch.object(ceph_hooks, 'get_ipv6_addr',
lambda **kwargs: ["2a01:348:2f4:0:685e:5748:ae62:209f"])
@patch.object(ceph_hooks, 'cmp_pkgrevno', lambda *args: 1)
@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_networks', lambda *args: "")
@patch.object(ceph_hooks, 'leader_get', lambda *args: '1234')
@patch.object(ceph, 'config')
@patch.object(ceph_hooks, 'config')
def test_get_ceph_context_prefer_ipv6(self, mock_config, mock_config2,
_get_rbd_features):
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': 'cephx',
'ceph_cluster_network': '',
'ceph_public_network': '',
'cluster_addr': '2a01:348:2f4:0:685e:5748:ae62:209f',
'dio': 'true',
'fsid': '1234',
'loglevel': 1,
'mon_hosts': '2a01:348:2f4:0:685e:5748:ae62:209f '
'2a01:348:2f4:0:685e:5748:ae62:20a0',
'mon_data_avail_warn': 30,
'mon_data_avail_crit': 5,
'old_auth': False,
'public_addr': '2a01:348:2f4:0:685e:5748:ae62:209f',
'use_syslog': 'true',
'ms_bind_ipv4': False,
'ms_bind_ipv6': True}
self.assertEqual(ctxt, expected)

@patch.object(ceph_hooks, 'config')
def test_nrpe_dependency_installed(self, mock_config):
config = copy.deepcopy(CHARM_CONFIG)
Expand Down

0 comments on commit 07af099

Please sign in to comment.