diff --git a/config.yaml b/config.yaml index 3e8f213..7d94134 100644 --- a/config.yaml +++ b/config.yaml @@ -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 diff --git a/hooks/utils.py b/hooks/utils.py index 3720d1b..e8d4eb1 100644 --- a/hooks/utils.py +++ b/hooks/utils.py @@ -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())