From: Martin Schwenke Date: Wed, 24 Jun 2020 01:20:24 +0000 (+1000) Subject: ctdb: Change NAT gateway to use leader/follower X-Git-Tag: talloc-2.3.2~993 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16b848553da47f0716d74c13bbbfba50ef5d2cd1;p=thirdparty%2Fsamba.git ctdb: Change NAT gateway to use leader/follower Instead of master/slave. Nearly all of these are simple textual substitutions, which preserve the case of the original. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/events/legacy/11.natgw.script b/ctdb/config/events/legacy/11.natgw.script index 18b064a1efb..b02ff7a6bf4 100755 --- a/ctdb/config/events/legacy/11.natgw.script +++ b/ctdb/config/events/legacy/11.natgw.script @@ -23,14 +23,14 @@ ctdb_setup_state_dir "failover" "$service_name" # shellcheck disable=SC2154 natgw_cfg_new="${script_state_dir}/cfg_new" natgw_cfg_old="${script_state_dir}/cfg_old" -natgw_master_old="${script_state_dir}/master_old" +natgw_leader_old="${script_state_dir}/leader_old" -ctdb_natgw_slave_only () +ctdb_natgw_follower_only () { _ip_address=$(ctdb_get_ip_address) awk -v my_ip="$_ip_address" \ - '$1 == my_ip { if ($2 ~ "slave-only") { exit 0 } else { exit 1 } }' \ + '$1 == my_ip { if ($2 ~ "follower-only") { exit 0 } else { exit 1 } }' \ "$CTDB_NATGW_NODES" } @@ -38,7 +38,7 @@ natgw_check_config () { [ -r "$CTDB_NATGW_NODES" ] || \ die "error: CTDB_NATGW_NODES=${CTDB_NATGW_NODES} unreadable" - if ! ctdb_natgw_slave_only ; then + if ! ctdb_natgw_follower_only ; then [ -n "$CTDB_NATGW_PUBLIC_IP" ] || \ die "Invalid configuration: CTDB_NATGW_PUBLIC_IP not set" [ -n "$CTDB_NATGW_PUBLIC_IFACE" ] || \ @@ -113,7 +113,7 @@ natgw_clear () fi } -natgw_set_master () +natgw_set_leader () { set_proc sys/net/ipv4/ip_forward 1 iptables -A POSTROUTING -t nat \ @@ -141,7 +141,7 @@ natgw_set_master () done } -natgw_set_slave () +natgw_set_follower () { _natgwip="$1" @@ -151,33 +151,33 @@ natgw_set_slave () done } -natgw_ensure_master () +natgw_ensure_leader () { # Intentional word splitting here # shellcheck disable=SC2046 - set -- $("${CTDB_HELPER_BINDIR}/ctdb_natgw" master) - natgwmaster="${1:--1}" # Default is -1, for failure above + set -- $("${CTDB_HELPER_BINDIR}/ctdb_natgw" leader) + natgwleader="${1:--1}" # Default is -1, for failure above natgwip="$2" - if [ "$natgwmaster" = "-1" ]; then + if [ "$natgwleader" = "-1" ]; then # Fail... - die "There is no NATGW master node" + die "There is no NATGW leader node" fi } -natgw_master_has_changed () +natgw_leader_has_changed () { - if [ -r "$natgw_master_old" ] ; then - read _old_natgwmaster <"$natgw_master_old" + if [ -r "$natgw_leader_old" ] ; then + read _old_natgwleader <"$natgw_leader_old" else - _old_natgwmaster="" + _old_natgwleader="" fi - [ "$_old_natgwmaster" != "$natgwmaster" ] + [ "$_old_natgwleader" != "$natgwleader" ] } natgw_save_state () { - echo "$natgwmaster" >"$natgw_master_old" + echo "$natgwleader" >"$natgw_leader_old" # Created by natgw_config_has_changed() mv "$natgw_cfg_new" "$natgw_cfg_old" } @@ -205,17 +205,17 @@ startup) updatenatgw|ipreallocated) natgw_check_config - natgw_ensure_master + natgw_ensure_leader - natgw_config_has_changed || natgw_master_has_changed || exit 0 + natgw_config_has_changed || natgw_leader_has_changed || exit 0 natgw_clear pnn=$(ctdb_get_pnn) - if [ "$pnn" = "$natgwmaster" ]; then - natgw_set_master + if [ "$pnn" = "$natgwleader" ]; then + natgw_set_leader else - natgw_set_slave "$natgwip" + natgw_set_follower "$natgwip" fi # flush our route cache diff --git a/ctdb/doc/ctdb-script.options.5.xml b/ctdb/doc/ctdb-script.options.5.xml index fe0517fe071..d46de369c5c 100644 --- a/ctdb/doc/ctdb-script.options.5.xml +++ b/ctdb/doc/ctdb-script.options.5.xml @@ -125,9 +125,9 @@ when they do not host any public IP addresses. For example, it allows unhealthy nodes to reliably communicate with external infrastructure. One node in a NAT gateway group will - be designated as the NAT gateway master node and other (slave) + be designated as the NAT gateway leader node and other (follower) nodes will be configured with fallback routes via the NAT - gateway master node. For more information, see the + gateway leader node. For more information, see the NAT GATEWAY section in ctdb 7. @@ -140,12 +140,12 @@ IPADDR is an alternate network gateway to use on the NAT - gateway master node. If set, a fallback default route + gateway leader node. If set, a fallback default route is added via this network gateway. No default. Setting this variable is optional - if not - set that no route is created on the NAT gateway master + set that no route is created on the NAT gateway leader node. @@ -161,7 +161,7 @@ File format: -IPADDR slave-only +IPADDR follower-only @@ -169,8 +169,8 @@ gateway group. - If "slave-only" is specified then the corresponding node - can not be the NAT gateway master node. In this case + If "follower-only" is specified then the corresponding node + can not be the NAT gateway leader node. In this case CTDB_NATGW_PUBLIC_IFACE and CTDB_NATGW_PUBLIC_IP are optional and unused. @@ -187,7 +187,7 @@ IPADDR/MASK is the private sub-network that is - internally routed via the NAT gateway master node. This + internally routed via the NAT gateway leader node. This is usually the private network that is used for node addresses. @@ -216,7 +216,7 @@ IPADDR/MASK indicates the IP address that is used for outgoing traffic (originating from - CTDB_NATGW_PRIVATE_NETWORK) on the NAT gateway master + CTDB_NATGW_PRIVATE_NETWORK) on the NAT gateway leader node. This must not be a configured public IP address. @@ -239,19 +239,19 @@ If GATEWAY is specified then the corresponding route on - the NATGW master node will be via GATEWAY. Such routes + the NATGW leader node will be via GATEWAY. Such routes are created even if CTDB_NATGW_DEFAULT_GATEWAY is not specified. If GATEWAY is not specified for some networks then routes are only created on the NATGW - master node for those networks if + leader node for those networks if CTDB_NATGW_DEFAULT_GATEWAY is specified. This should be used with care to avoid causing traffic to unnecessarily double-hop through the NAT gateway - master, even when a node is hosting public IP addresses. + leader, even when a node is hosting public IP addresses. Each specified network or host should probably have a corresponding automatically created link route or static route to avoid this. diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index fe2b675ff2c..9b530087e92 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -445,7 +445,7 @@ Duration of last recovery/failover: 2.248552 seconds - natgw {master|list|status} + natgw {leader|list|status} This command shows different aspects of NAT gateway status. For an overview of CTDB's NAT gateway functionality please see @@ -456,11 +456,11 @@ Duration of last recovery/failover: 2.248552 seconds - master + leader Show the PNN and private IP address of the current NAT - gateway master node. + gateway leader node. Example output: @@ -475,14 +475,14 @@ Duration of last recovery/failover: 2.248552 seconds List the private IP addresses of nodes in the current - NAT gateway group, annotating the master node. + NAT gateway group, annotating the leader node. Example output: 192.168.2.200 -192.168.2.201 MASTER +192.168.2.201 LEADER 192.168.2.202 192.168.2.203 diff --git a/ctdb/doc/ctdb.7.xml b/ctdb/doc/ctdb.7.xml index 2079ed713e3..5ec69e4c871 100644 --- a/ctdb/doc/ctdb.7.xml +++ b/ctdb/doc/ctdb.7.xml @@ -715,13 +715,13 @@ CTDB_LVS_NODES=/usr/local/etc/ctdb/lvs_nodes In each NATGW group, one of the nodes is selected by CTDB to - be the NATGW master and the other nodes are consider to be - NATGW slaves. NATGW slaves establish a fallback default route - to the NATGW master via the private network. When a NATGW - slave hosts no public IP addresses then it will use this route - for outbound connections. The NATGW master hosts the NATGW + be the NATGW leader and the other nodes are consider to be + NATGW followers. NATGW followers establish a fallback default route + to the NATGW leader via the private network. When a NATGW + follower hosts no public IP addresses then it will use this route + for outbound connections. The NATGW leader hosts the NATGW public IP address and routes outgoing connections from - slave nodes via this IP address. It also establishes a + follower nodes via this IP address. It also establishes a fallback default route. @@ -742,9 +742,9 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1 Normally any node in a NATGW group can act as the NATGW - master. Some configurations may have special nodes that lack + leader. Some configurations may have special nodes that lack connectivity to a public network. In such cases, those nodes - can be flagged with the "slave-only" option in the + can be flagged with the "follower-only" option in the CTDB_NATGW_NODES file to limit the NATGW functionality of those nodes. @@ -765,15 +765,15 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1 When the NATGW functionality is used, one of the nodes is selected to act as a NAT gateway for all the other nodes in the group when they need to communicate with the external - services. The NATGW master is selected to be a node that is + services. The NATGW leader is selected to be a node that is most likely to have usable networks. - The NATGW master hosts the NATGW public IP address + The NATGW leader hosts the NATGW public IP address CTDB_NATGW_PUBLIC_IP on the configured public interfaces CTDB_NATGW_PUBLIC_IFACE and acts as - a router, masquerading outgoing connections from slave nodes + a router, masquerading outgoing connections from follower nodes via this IP address. If CTDB_NATGW_DEFAULT_GATEWAY is set then it also establishes a fallback default route to the configured @@ -783,8 +783,8 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1 - A NATGW slave establishes its fallback default route to the - NATGW master via the private network + A NATGW follower establishes its fallback default route to the + NATGW leader via the private network CTDB_NATGW_PRIVATE_NETWORKwith a metric of 10. This route is used for outbound connections when no other default route is available because the node hosts no public diff --git a/ctdb/tests/UNIT/eventscripts/11.natgw.002.sh b/ctdb/tests/UNIT/eventscripts/11.natgw.002.sh index 5e3f2d3a224..90b13991fe5 100755 --- a/ctdb/tests/UNIT/eventscripts/11.natgw.002.sh +++ b/ctdb/tests/UNIT/eventscripts/11.natgw.002.sh @@ -7,7 +7,7 @@ define_test "missing config file" setup setup_ctdb_natgw <