Switch default transport to unicast

Unicast is generally alot more reliable and is guaranteed to work
in all network configurations unlike multicast.

Optimize context build for unicast configuration - its possible to
build the corosync cluster prior to the principle charm presenting
multicast only configuration options.

Change-Id: I7c4f559325234401a7b6f7aa26114349d07817ad
This commit is contained in:
James Page 2016-08-05 09:48:20 +01:00
parent f313da0507
commit 2edb98b7df
2 changed files with 35 additions and 20 deletions

View File

@ -15,25 +15,32 @@ options:
order for this charm to function correctly, the privacy extension must be
disabled and a non-temporary address must be configured/available on
your network interface.
corosync_transport:
type: string
default: "unicast"
description: |
Two supported modes are multicast (udp) or unicast (udpu)
corosync_mcastaddr:
type: string
default: 226.94.1.1
description: |
Multicast IP address to use for exchanging messages over the network.
If multiple clusters are on the same bindnetaddr network, this value
can be changed.
can be changed. Only used when corosync_transport = multicast.
corosync_bindiface:
type: string
default:
description: |
Default network interface on which HA cluster will bind to communication
with the other members of the HA Cluster.
with the other members of the HA Cluster. Defaults to the network
interface hosting the units private-address. Only used when
corosync_transport = multicast.
corosync_mcastport:
type: int
default:
description: |
Default multicast port number that will be used to communicate between
HA Cluster nodes.
HA Cluster nodes. Only used when corosync_transport = multicast.
corosync_key:
type: string
default: "64RxJNcCkwo8EJYBsaacitUvbQp5AW4YolJi5/2urYZYp2jfLxY+3IUCOaAUJHPle4Yqfy+WBXO0I/6ASSAjj9jaiHVNaxmVhhjcmyBqy2vtPf+m+0VxVjUXlkTyYsODwobeDdO3SIkbIABGfjLTu29yqPTsfbvSYr6skRb9ne0="
@ -104,11 +111,6 @@ options:
Specifies the corosync.conf network mtu. If unset, the default
corosync.conf value is used (currently 1500). See 'man corosync.conf' for
detailed information on this config option.
corosync_transport:
type: string
default: "multicast"
description: |
Two supported modes are multicast (udp) or unicast (udpu)
nagios_context:
default: "juju"
type: string

View File

@ -212,18 +212,25 @@ def get_corosync_conf():
ip_version = 'ipv4'
bindnetaddr = get_network_address
transport = get_transport()
# NOTE(jamespage) use local charm configuration over any provided by
# principle charm
conf = {
'corosync_bindnetaddr':
bindnetaddr(config('corosync_bindiface')),
'corosync_mcastport': config('corosync_mcastport'),
'corosync_mcastaddr': config('corosync_mcastaddr'),
'ip_version': ip_version,
'ha_nodes': get_ha_nodes(),
'transport': get_transport(),
'transport': transport,
}
# NOTE(jamespage): only populate multicast configuration if udp is
# configured
if transport == 'udp':
conf.update({
'corosync_bindnetaddr': bindnetaddr(config('corosync_bindiface')),
'corosync_mcastport': config('corosync_mcastport'),
'corosync_mcastaddr': config('corosync_mcastaddr')
})
if config('prefer-ipv6'):
conf['nodeid'] = get_corosync_id(local_unit())
@ -241,18 +248,24 @@ def get_corosync_conf():
conf = {}
for relid in relation_ids('ha'):
for unit in related_units(relid):
bindiface = relation_get('corosync_bindiface',
unit, relid)
conf = {
'corosync_bindnetaddr': bindnetaddr(bindiface),
'corosync_mcastport': relation_get('corosync_mcastport',
unit, relid),
'corosync_mcastaddr': config('corosync_mcastaddr'),
'ip_version': ip_version,
'ha_nodes': get_ha_nodes(),
'transport': get_transport(),
'transport': transport,
}
# NOTE(jamespage): only populate multicast configuration if udpu is
# configured
if transport == 'udp':
bindiface = relation_get('corosync_bindiface',
unit, relid)
conf.update({
'corosync_bindnetaddr': bindnetaddr(bindiface),
'corosync_mcastport': relation_get('corosync_mcastport',
unit, relid),
'corosync_mcastaddr': config('corosync_mcastaddr'),
})
if config('prefer-ipv6'):
conf['nodeid'] = get_corosync_id(local_unit())