-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In some environments, the call to socket.gethostname resolves to the fqdn. This causes the charm to use the fqdn for the rabbit hostname, but rabbit always uses the equivalent of `hostname -s` by default. The charm already uses the results of socket.gethostname() in relation data everywhere, and some users have applied a workaround of RABBITMQ_USE_LONGNAME to the rabbitmq-env.conf file in order to allow the nodes to start and the charm to manage it. This change detects the scenario where the socket.gethostname() call results in a name that contains a '.' and treats this as the long node name scenario. It will detect this on the install hook and render the necessary configuration files and restart the rabbit service to ensure that the node specified by the fqdn is used. This allows for the charm to manage the rabbit cluster in these particular scenarios. What this change does not deal with, is the potential that the hostname resolution can change from hostname to fqdn (or vice versa). This would require that the node be gracefully renamed in the rabbitmq-cluster and is a much bigger/more involved change. As the current charm makes assumptions that the hostname is stable, this is left to future enhancements for the charm. Related-Bug: #1976523 Change-Id: I27013e0f998fd0f0edf31b029a857af652ec6e8e
- Loading branch information
Showing
8 changed files
with
127 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,17 +87,18 @@ def test_write_all(self, log, render): | |
self.assertTrue(log.called) | ||
|
||
|
||
RABBITMQCTL_CLUSTERSTATUS_RUNNING = b"""Cluster status of node 'rabbit@juju-devel3-machine-19' ... | ||
[{nodes, | ||
[{disc, | ||
RABBITMQCTL_CLUSTERSTATUS_RUNNING = \ | ||
b"""Cluster status of node 'rabbit@juju-devel3-machine-19' ... | ||
[{nodes, | ||
[{disc, | ||
['rabbit@juju-devel3-machine-14','rabbit@juju-devel3-machine-19']}, | ||
{ram, | ||
['rabbit@juju-devel3-machine-42']}]}, | ||
{running_nodes, | ||
['rabbit@juju-devel3-machine-14','rabbit@juju-devel3-machine-19']}, | ||
{ram, | ||
['rabbit@juju-devel3-machine-42']}]}, | ||
{running_nodes, | ||
['rabbit@juju-devel3-machine-14','rabbit@juju-devel3-machine-19']}, | ||
{cluster_name,<<"[email protected]">>}, | ||
{partitions,[]}] | ||
""" | ||
{cluster_name,<<"[email protected]">>}, | ||
{partitions,[]}] | ||
""" | ||
|
||
RABBITMQCTL_CLUSTERSTATUS_RUNNING_382 = b""" | ||
{"running_nodes": [ | ||
|
@@ -111,12 +112,13 @@ def test_write_all(self, log, render): | |
""" | ||
|
||
|
||
RABBITMQCTL_CLUSTERSTATUS_SOLO = b"""Cluster status of node 'rabbit@juju-devel3-machine-14' ... | ||
[{nodes,[{disc,['rabbit@juju-devel3-machine-14']}]}, | ||
{running_nodes,['rabbit@juju-devel3-machine-14']}, | ||
{cluster_name,<<"[email protected]">>}, | ||
{partitions,[]}] | ||
""" | ||
RABBITMQCTL_CLUSTERSTATUS_SOLO = \ | ||
b"""Cluster status of node 'rabbit@juju-devel3-machine-14' ... | ||
[{nodes,[{disc,['rabbit@juju-devel3-machine-14']}]}, | ||
{running_nodes,['rabbit@juju-devel3-machine-14']}, | ||
{cluster_name,<<"[email protected]">>}, | ||
{partitions,[]}] | ||
""" | ||
|
||
|
||
RABBITMQCTL_CLUSTERSTATUS_SOLO_382 = b""" | ||
|
@@ -454,6 +456,14 @@ def test_get_node_hostname(self, mock_get_hostname): | |
'juju-devel3-machine-13') | ||
mock_get_hostname.assert_called_with('192.168.20.50', fqdn=False) | ||
|
||
@mock.patch('socket.gethostname') | ||
def test_use_long_node_name(self, mock_gethostname): | ||
mock_gethostname.return_value = 'foo.bar' | ||
self.assertTrue(rabbit_utils.use_long_node_name()) | ||
|
||
mock_gethostname.return_value = 'foo' | ||
self.assertFalse(rabbit_utils.use_long_node_name()) | ||
|
||
@mock.patch('rabbit_utils.peer_retrieve') | ||
def test_leader_node(self, mock_peer_retrieve): | ||
mock_peer_retrieve.return_value = 'juju-devel3-machine-15' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters