1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2020-06-24 11:20:24 +10:00 committed by Amitay Isaacs
parent 5ce6133a75
commit 16b848553d
36 changed files with 189 additions and 189 deletions

View File

@ -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

View File

@ -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
<citetitle>NAT GATEWAY</citetitle> section in
<citerefentry><refentrytitle>ctdb</refentrytitle>
<manvolnum>7</manvolnum></citerefentry>.
@ -140,12 +140,12 @@
<listitem>
<para>
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.
</para>
<para>
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.
</para>
</listitem>
@ -161,7 +161,7 @@
<para>
File format:
<screen>
<parameter>IPADDR</parameter> <optional>slave-only</optional>
<parameter>IPADDR</parameter> <optional>follower-only</optional>
</screen>
</para>
<para>
@ -169,8 +169,8 @@
gateway group.
</para>
<para>
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
<varname>CTDB_NATGW_PUBLIC_IFACE</varname> and
<varname>CTDB_NATGW_PUBLIC_IP</varname> are optional and
unused.
@ -187,7 +187,7 @@
<listitem>
<para>
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.
</para>
@ -216,7 +216,7 @@
<para>
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 <emphasis>must not</emphasis> be a
configured public IP address.
</para>
@ -239,19 +239,19 @@
</para>
<para>
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
<varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> 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
<varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is
specified.
</para>
<para>
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.

View File

@ -445,7 +445,7 @@ Duration of last recovery/failover: 2.248552 seconds
</refsect2>
<refsect2>
<title>natgw {master|list|status}</title>
<title>natgw {leader|list|status}</title>
<para>
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
<variablelist>
<varlistentry>
<term>master</term>
<term>leader</term>
<listitem>
<para>
Show the PNN and private IP address of the current NAT
gateway master node.
gateway leader node.
</para>
<para>
Example output:
@ -475,14 +475,14 @@ Duration of last recovery/failover: 2.248552 seconds
<listitem>
<para>
List the private IP addresses of nodes in the current
NAT gateway group, annotating the master node.
NAT gateway group, annotating the leader node.
</para>
<para>
Example output:
</para>
<screen>
192.168.2.200
192.168.2.201 MASTER
192.168.2.201 LEADER
192.168.2.202
192.168.2.203
</screen>

View File

@ -715,13 +715,13 @@ CTDB_LVS_NODES=/usr/local/etc/ctdb/lvs_nodes
</para>
<para>
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.
</para>
</refsect2>
@ -742,9 +742,9 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1
<para>
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
<varname>CTDB_NATGW_NODES</varname> file to limit the NATGW
functionality of those nodes.
</para>
@ -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.
</para>
<para>
The NATGW master hosts the NATGW public IP address
The NATGW leader hosts the NATGW public IP address
<varname>CTDB_NATGW_PUBLIC_IP</varname> on the configured public
interfaces <varname>CTDB_NATGW_PUBLIC_IFACE</varname> and acts as
a router, masquerading outgoing connections from slave nodes
a router, masquerading outgoing connections from follower nodes
via this IP address. If
<varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> 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
</para>
<para>
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
<varname>CTDB_NATGW_PRIVATE_NETWORK</varname>with a metric of 10.
This route is used for outbound connections when no other
default route is available because the node hosts no public

View File

@ -7,7 +7,7 @@ define_test "missing config file"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "CTDB_NATGW_PUBLIC_IFACE unset, not slave-only"
define_test "CTDB_NATGW_PUBLIC_IFACE unset, not follower-only"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "CTDB_NATGW_PUBLIC_IP unset, not slave-only"
define_test "CTDB_NATGW_PUBLIC_IP unset, not follower-only"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "master node, basic configuration"
define_test "leader node, basic configuration"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -19,5 +19,5 @@ simple_test_event "ipreallocated"
ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "slave node, basic configuration"
define_test "follower node, basic configuration"
setup
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -16,8 +16,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
ok "default via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_slave_ip_addr_show
ok_natgw_follower_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "master node, no gateway"
define_test "leader node, no gateway"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -23,5 +23,5 @@ simple_test_event "ipreallocated"
ok_null
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "slave node, no gateway"
define_test "follower node, no gateway"
setup
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -20,8 +20,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
ok "default via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_slave_ip_addr_show
ok_natgw_follower_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -6,10 +6,10 @@ define_test "basic configuration, multiple transitions"
setup
echo "*** Master node..."
echo "*** Leader node..."
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -21,14 +21,14 @@ simple_test_event "ipreallocated"
ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
echo "*** Slave node..."
echo "*** Follower node..."
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -36,16 +36,16 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
ok "default via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_slave_ip_addr_show
ok_natgw_follower_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
echo "*** Master node again..."
echo "*** Leader node again..."
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -57,5 +57,5 @@ simple_test_event "ipreallocated"
ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "master node, static routes"
define_test "leader node, static routes"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -20,8 +20,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
ok_natgw_leader_static_routes
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "slave node, static routes"
define_test "follower node, static routes"
setup
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -20,8 +20,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_slave_static_routes
ok_natgw_follower_static_routes
simple_test_command ip route show
ok_natgw_slave_ip_addr_show
ok_natgw_follower_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "master node, static routes, custom gateway"
define_test "leader node, static routes, custom gateway"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -20,8 +20,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
ok_natgw_leader_static_routes
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "slave node, static routes, custom gateway"
define_test "follower node, static routes, custom gateway"
setup
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -20,8 +20,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_slave_static_routes
ok_natgw_follower_static_routes
simple_test_command ip route show
ok_natgw_slave_ip_addr_show
ok_natgw_follower_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -10,10 +10,10 @@ setup_script_options <<EOF
CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24@10.1.1.253"
EOF
echo "*** Master node..."
echo "*** Leader node..."
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -22,17 +22,17 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
ok_natgw_leader_static_routes
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
echo "*** Slave node..."
echo "*** Follower node..."
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -40,16 +40,16 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_slave_static_routes
ok_natgw_follower_static_routes
simple_test_command ip route show
ok_natgw_slave_ip_addr_show
ok_natgw_follower_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
echo "*** Master node again..."
echo "*** Leader node again..."
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -58,8 +58,8 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
ok_natgw_leader_static_routes
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,7 +2,7 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "master node, static routes, custom gateway, config change"
define_test "leader node, static routes, custom gateway, config change"
setup
@ -14,7 +14,7 @@ echo "##################################################"
echo "Static routes..."
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24
@ -23,10 +23,10 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
ok_natgw_leader_static_routes
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
echo "##################################################"
@ -42,7 +42,7 @@ simple_test_event "ipreallocated"
ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX metric 10 "
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
echo "##################################################"
@ -55,8 +55,8 @@ EOF
ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
ok_natgw_leader_static_routes
simple_test_command ip route show
ok_natgw_master_ip_addr_show
ok_natgw_leader_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "slave-only, CTDB_NATGW_PUBLIC_IFACE unset"
define_test "follower-only, CTDB_NATGW_PUBLIC_IFACE unset"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 slave-only
192.168.1.22 master
192.168.1.21 follower-only
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -20,5 +20,5 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
ok "default via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
simple_test_command ip route show

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "slave-only, CTDB_NATGW_PUBLIC_IP unset"
define_test "follower-only, CTDB_NATGW_PUBLIC_IP unset"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 slave-only
192.168.1.22 master
192.168.1.21 follower-only
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF
@ -21,5 +21,5 @@ EOF
ok_null
simple_test_event "ipreallocated"
ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
ok "default via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
simple_test_command ip route show

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, slave, up"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, follower, up"
setup
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF

View File

@ -2,13 +2,13 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, slave, down"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, follower, down"
setup
setup_ctdb_natgw <<EOF
192.168.1.21
192.168.1.22 master
192.168.1.22 leader
192.168.1.23
192.168.1.24
EOF

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, master, up"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, leader, up"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, master, down"
define_test "Monitor CTDB_NATGW_PUBLIC_IFACE, leader, down"
setup
setup_ctdb_natgw <<EOF
192.168.1.21 master
192.168.1.21 leader
192.168.1.22
192.168.1.23
192.168.1.24

View File

@ -14,12 +14,12 @@ setup_ctdb_natgw ()
# Read from stdin
while read _ip _opts ; do
case "$_opts" in
master)
export FAKE_CTDB_NATGW_MASTER="$_ip"
leader)
export FAKE_CTDB_NATGW_LEADER="$_ip"
echo "$_ip"
;;
slave-only)
printf "%s\tslave-only\n" "$_ip"
follower-only)
printf "%s\tfollower-only\n" "$_ip"
;;
*)
echo "$_ip"
@ -43,7 +43,7 @@ CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
EOF
}
ok_natgw_master_ip_addr_show ()
ok_natgw_leader_ip_addr_show ()
{
_mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" |
cksum |
@ -60,7 +60,7 @@ ok_natgw_master_ip_addr_show ()
EOF
}
ok_natgw_slave_ip_addr_show ()
ok_natgw_follower_ip_addr_show ()
{
_mac=$(echo "$CTDB_NATGW_PUBLIC_IFACE" |
cksum |
@ -72,7 +72,7 @@ ok_natgw_slave_ip_addr_show ()
EOF
}
ok_natgw_master_static_routes ()
ok_natgw_leader_static_routes ()
{
_nl="
"
@ -97,7 +97,7 @@ ok_natgw_master_static_routes ()
ok "$_t"
}
ok_natgw_slave_static_routes ()
ok_natgw_follower_static_routes ()
{
_nl="
"
@ -112,7 +112,7 @@ ok_natgw_slave_static_routes ()
# implicitly added by "ip route" but our stub doesn't
# do this and adds "ethXXX".
_t="${_t}${_t:+${_nl}}"
_t="${_t}${_net} via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
_t="${_t}${_net} via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
done
_t=$(echo "$_t" | sort)
ok "$_t"

View File

@ -10,25 +10,25 @@ not_implemented ()
exit $not_implemented_exit_code
}
ctdb_natgw_master ()
ctdb_natgw_leader ()
{
[ -r "$CTDB_NATGW_NODES" ] || \
die "error: missing CTDB_NATGW_NODES=${CTDB_NATGW_NODES}"
# Determine the master node
_master="-1 0.0.0.0"
# Determine the leader node
_leader="-1 0.0.0.0"
_pnn=0
while read _ip ; do
if [ "$FAKE_CTDB_NATGW_MASTER" = "$_ip" ] ; then
_master="${_pnn} ${_ip}"
if [ "$FAKE_CTDB_NATGW_LEADER" = "$_ip" ] ; then
_leader="${_pnn} ${_ip}"
break
fi
_pnn=$(($_pnn + 1))
done <"$CTDB_NATGW_NODES"
echo "$_master"
echo "$_leader"
}
case "$1" in
master) ctdb_natgw_master "$@" ;;
leader) ctdb_natgw_leader "$@" ;;
*) not_implemented "$1" ;;
esac

View File

@ -23,12 +23,12 @@ required_result 0 <<EOF
0 192.168.20.41
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41 MASTER
192.168.20.41 LEADER
192.168.20.42
192.168.20.43
EOF

View File

@ -23,13 +23,13 @@ required_result 0 <<EOF
1 192.168.20.42
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41
192.168.20.42 MASTER
192.168.20.42 LEADER
192.168.20.43
EOF

View File

@ -22,13 +22,13 @@ required_result 0 <<EOF
2 192.168.20.43
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41
192.168.20.43 MASTER
192.168.20.43 LEADER
EOF
simple_test list

View File

@ -23,14 +23,14 @@ required_result 0 <<EOF
2 192.168.20.43
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41
192.168.20.42
192.168.20.43 MASTER
192.168.20.43 LEADER
EOF
simple_test list

View File

@ -23,12 +23,12 @@ required_result 0 <<EOF
0 192.168.20.41
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41 MASTER
192.168.20.41 LEADER
192.168.20.42
192.168.20.43
EOF

View File

@ -2,10 +2,10 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, node 0 is slave-only, all stopped"
define_test "3 nodes, node 0 is follower-only, all stopped"
setup_natgw <<EOF
192.168.20.41 slave-only
192.168.20.41 follower-only
192.168.20.42
192.168.20.43
EOF
@ -23,13 +23,13 @@ required_result 0 <<EOF
1 192.168.20.42
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41 slave-only
192.168.20.42 MASTER
192.168.20.41 follower-only
192.168.20.42 LEADER
192.168.20.43
EOF

View File

@ -2,12 +2,12 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "3 nodes, all nodes are slave-only, all stopped"
define_test "3 nodes, all nodes are follower-only, all stopped"
setup_natgw <<EOF
192.168.20.41 slave-only
192.168.20.42 slave-only
192.168.20.43 slave-only
192.168.20.41 follower-only
192.168.20.42 follower-only
192.168.20.43 follower-only
EOF
setup_ctdbd <<EOF
@ -22,14 +22,14 @@ EOF
required_result 2 <<EOF
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41 slave-only
192.168.20.42 slave-only
192.168.20.43 slave-only
192.168.20.41 follower-only
192.168.20.42 follower-only
192.168.20.43 follower-only
EOF
simple_test list

View File

@ -23,13 +23,13 @@ required_result 0 <<EOF
1 192.168.20.42
EOF
simple_test master
simple_test leader
#####
required_result 0 <<EOF
192.168.20.41
192.168.20.42 MASTER
192.168.20.42 LEADER
192.168.20.43
EOF

View File

@ -6027,7 +6027,7 @@ static const struct ctdb_cmd {
"show event script status",
"[init|setup|startup|monitor|takeip|releaseip|ipreallocated]" },
{ "natgw", control_natgw, false, false,
"show natgw configuration", "master|list|status" },
"show natgw configuration", "leader|list|status" },
{ "getreclock", control_getreclock, false, true,
"get recovery lock file", NULL },
{ "setlmasterrole", control_setlmasterrole, false, true,

View File

@ -23,8 +23,8 @@ cat <<EOF
$0 <option>
<option> is one of:
master Display node number and private IP address of master node
list List private IP addresses of nodes in group, annotate master
leader Display node number and private IP address of leader node
list List private IP addresses of nodes in group, annotate leader
status Show status of nodes in NAT gateway group
EOF
exit 1
@ -68,7 +68,7 @@ get_natgw_nodes ()
\#*) continue ;;
esac
case "$_options" in
slave-only|"") : ;;
follower-only|"") : ;;
*) die "${prog}: Invalid options \"${_options}\" in \"$CTDB_NATGW_NODES\""
esac
done <<EOF
@ -78,15 +78,15 @@ EOF
return 0
}
# Print the PNN and IP address of the NAT gateway master node
find_master ()
# Print the PNN and IP address of the NAT gateway leader node
find_leader ()
{
get_natgw_nodes || \
die "${prog}: NAT gateway nodes file \"$CTDB_NATGW_NODES\" not found"
get_nodestatus_X || \
die "${prog}: Unable to get status of nodes"
# $_ms is an @-delimited list of nodes that are allowed to be the master
# $_ms is an @-delimited list of nodes that are allowed to be the leader
_ms="@"
while read _ip _options ; do
case "$_options" in
@ -99,7 +99,7 @@ EOF
# Now filter by $ms and by status of nodes...
# Note that the 3 awk invocations below have "||" between them, so
# the first to succeed will select the master node.
# the first to succeed will select the leader node.
# First try for a fully active and healthy node, so must not be
# DISABLED, UNHEALTHY or INACTIVE (last covers DISCONNECTED,
@ -131,21 +131,21 @@ $nodestatus_X
EOF
}
# List all nodes in the NAT gateway group, annotating the master node
# List all nodes in the NAT gateway group, annotating the leader node
nodes_list ()
{
get_natgw_nodes || \
die "${prog}: NAT gateway nodes file \"$CTDB_NATGW_NODES\" not found"
# Intentional word splitting here
# shellcheck disable=SC2046
set -- $(find_master) || \
die "${prog}: Unable to determine NAT gateway master node"
_master_ip="$2"
set -- $(find_leader) || \
die "${prog}: Unable to determine NAT gateway leader node"
_leader_ip="$2"
# Annotate the master node
# Annotate the leader node
while read _ip _options ; do
if [ "$_ip" = "$_master_ip" ] ; then
_options="MASTER${_options:+,}${_options}"
if [ "$_ip" = "$_leader_ip" ] ; then
_options="LEADER${_options:+,}${_options}"
fi
# There is no other way to do this and keep shellcheck happy.
# The tab character must be in the format string and the
@ -187,7 +187,7 @@ prog=$(basename "$0")
cmd="$1"
case "$cmd" in
master) find_master ;;
leader) find_leader ;;
list) nodes_list ;;
status) nodes_status ;;
*) usage ;;