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

ctdb: Change LVS to use leader/follower

Instead of master/slave.

Nearly all of these are simple textual substitutions, which preserve
the case of the original.    A couple of minor cleanups were made in the
documentation (such as "LVSMASTER" -> "LVS leader").

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2020-07-17 20:46:07 +10:00 committed by Amitay Isaacs
parent 16b848553d
commit f37b3cf2a6
19 changed files with 56 additions and 56 deletions

View File

@ -19,11 +19,11 @@ if ! type ipvsadm >/dev/null 2>&1 ; then
fi
lvs_slave_only ()
lvs_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_LVS_NODES"
}
@ -33,7 +33,7 @@ lvs_check_config ()
die "error: CTDB_LVS_NODES=${CTDB_LVS_NODES} unreadable"
[ -n "$CTDB_LVS_PUBLIC_IP" ] || \
die "Invalid configuration: CTDB_LVS_PUBLIC_IP not set"
if ! lvs_slave_only ; then
if ! lvs_follower_only ; then
[ -n "$CTDB_LVS_PUBLIC_IFACE" ] || \
die "Invalid configuration: CTDB_LVS_PUBLIC_IFACE not set"
fi
@ -78,9 +78,9 @@ ipreallocated)
"$CTDB_LVS_PUBLIC_IFACE" "$CTDB_LVS_PUBLIC_IP"
pnn=$(ctdb_get_pnn)
lvsmaster=$("${CTDB_HELPER_BINDIR}/ctdb_lvs" master)
if [ "$pnn" != "$lvsmaster" ] ; then
# This node is not the LVS master so change the IP address
lvsleader=$("${CTDB_HELPER_BINDIR}/ctdb_lvs" leader)
if [ "$pnn" != "$lvsleader" ] ; then
# This node is not the LVS leader so change the IP address
# to have scope "host" so this node won't respond to ARPs
ip addr del "${CTDB_LVS_PUBLIC_IP}/32" dev lo >/dev/null 2>&1
ip addr add "${CTDB_LVS_PUBLIC_IP}/32" dev lo scope host

View File

@ -451,7 +451,7 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
<para>
File format:
<screen>
<parameter>IPADDR</parameter> <optional>slave-only</optional>
<parameter>IPADDR</parameter> <optional>follower-only</optional>
</screen>
</para>
<para>
@ -459,8 +459,8 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
group.
</para>
<para>
If "slave-only" is specified then the corresponding node
can not be the LVS master node. In this case
If "follower-only" is specified then the corresponding node
can not be the LVS leader node. In this case
<varname>CTDB_LVS_PUBLIC_IFACE</varname> and
<varname>CTDB_LVS_PUBLIC_IP</varname> are optional and
unused.
@ -480,7 +480,7 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
<para>
INTERFACE is the network interface that clients will use
to connection to <varname>CTDB_LVS_PUBLIC_IP</varname>.
This is optional for slave-only nodes.
This is optional for follower-only nodes.
No default.
</para>
</listitem>

View File

@ -864,7 +864,7 @@ MonitorInterval = 15
</refsect2>
<refsect2>
<title>lvs {master|list|status}</title>
<title>lvs {leader|list|status}</title>
<para>
This command shows different aspects of LVS status. For an
overview of CTDB's LVS functionality please see the
@ -875,10 +875,10 @@ MonitorInterval = 15
<variablelist>
<varlistentry>
<term>master</term>
<term>leader</term>
<listitem>
<para>
Shows the PNN of the current LVS master node.
Shows the PNN of the current LVS leader node.
</para>
<para>
Example output:

View File

@ -528,13 +528,13 @@ Node 3:/usr/local/etc/ctdb/public_addresses
<para>
In each LVS group, one of the nodes is selected by CTDB to be
the LVS master. This node receives all traffic from clients
the LVS leader. This node receives all traffic from clients
coming in to the LVS public address and multiplexes it across
the internal network to one of the nodes that LVS is using.
When responding to the client, that node will send the data back
directly to the client, bypassing the LVS master node. The
command <command>ctdb lvs master</command> will show which node
is the current LVS master.
directly to the client, bypassing the LVS leader node. The
command <command>ctdb lvs leader</command> will show which node
is the current LVS leader.
</para>
<para>
@ -542,12 +542,12 @@ Node 3:/usr/local/etc/ctdb/public_addresses
<orderedlist>
<listitem>
<para>
Client sends request packet to LVSMASTER.
Client sends request packet to LVS leader.
</para>
</listitem>
<listitem>
<para>
LVSMASTER passes the request on to one node across the
LVS leader passes the request on to one node across the
internal network.
</para>
</listitem>
@ -572,7 +572,7 @@ Node 3:/usr/local/etc/ctdb/public_addresses
pattern is write-intensive since you will be limited in the
available network bandwidth that node can handle. LVS does work
very well for read-intensive workloads where only smallish READ
requests are going through the LVSMASTER bottleneck and the
requests are going through the LVS leader bottleneck and the
majority of the traffic volume (the data in the read replies)
goes straight from the processing node back to the clients. For
read-intensive i/o patterns you can achieve very high throughput
@ -631,21 +631,21 @@ CTDB_LVS_NODES=/usr/local/etc/ctdb/lvs_nodes
</screen>
<para>
Normally any node in an LVS group can act as the LVS master.
Normally any node in an LVS group can act as the LVS leader.
Nodes that are highly loaded due to other demands maybe
flagged with the "slave-only" option in the
flagged with the "follower-only" option in the
<varname>CTDB_LVS_NODES</varname> file to limit the LVS
functionality of those nodes.
</para>
<para>
LVS nodes file that excludes 192.168.1.4 from being
the LVS master node:
the LVS leader node:
</para>
<screen format="linespecific">
192.168.1.2
192.168.1.3
192.168.1.4 slave-only
192.168.1.4 follower-only
</screen>
</refsect2>

View File

@ -2,7 +2,7 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "nodes in config, no master (e.g. all inactive)"
define_test "nodes in config, no leader (e.g. all inactive)"
setup "10.1.1.201" "eth0" <<EOF
192.168.1.1

View File

@ -2,11 +2,11 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "nodes in config, other node is master"
define_test "nodes in config, other node is leader"
setup "10.1.1.201" "eth0" <<EOF
192.168.1.1
192.168.1.2 master
192.168.1.2 leader
192.168.1.3
EOF

View File

@ -2,10 +2,10 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "nodes in config, this is master"
define_test "nodes in config, this is leader"
setup "10.1.1.201" "eth0" <<EOF
192.168.1.1 master
192.168.1.1 leader
192.168.1.2
192.168.1.3
EOF

View File

@ -17,18 +17,18 @@ CTDB_LVS_PUBLIC_IP="$_ip"
CTDB_LVS_PUBLIC_IFACE="$_iface"
EOF
export FAKE_CTDB_LVS_MASTER=""
export FAKE_CTDB_LVS_LEADER=""
# Read from stdin
_pnn=0
while read _ip _opts ; do
case "$_opts" in
master)
FAKE_CTDB_LVS_MASTER="$_pnn"
leader)
FAKE_CTDB_LVS_LEADER="$_pnn"
echo "$_ip"
;;
slave-only)
printf "%s\tslave-only\n" "$_ip"
follower-only)
printf "%s\tfollower-only\n" "$_ip"
;;
*)
echo "$_ip"

View File

@ -13,7 +13,7 @@ not_implemented_exit_code=1
usage ()
{
cat >&2 <<EOF
Usage: $prog { master | list }
Usage: $prog { leader | list }
EOF
exit 1
}
@ -24,10 +24,10 @@ not_implemented ()
exit $not_implemented_exit_code
}
ctdb_lvs_master ()
ctdb_lvs_leader ()
{
if [ -n "$FAKE_CTDB_LVS_MASTER" ] ; then
echo "$FAKE_CTDB_LVS_MASTER"
if [ -n "$FAKE_CTDB_LVS_LEADER" ] ; then
echo "$FAKE_CTDB_LVS_LEADER"
return 0
else
return 255
@ -46,7 +46,7 @@ ctdb_lvs_list ()
######################################################################
case "$1" in
master) ctdb_lvs_master "$@" ;;
leader) ctdb_lvs_leader "$@" ;;
list) ctdb_lvs_list "$@" ;;
*) not_implemented "$1" ;;
esac

View File

@ -19,7 +19,7 @@ EOF
required_result 255 <<EOF
EOF
simple_test master
simple_test leader
#####

View File

@ -23,7 +23,7 @@ required_result 0 <<EOF
0
EOF
simple_test master
simple_test leader
#####

View File

@ -22,7 +22,7 @@ required_result 0 <<EOF
0
EOF
simple_test master
simple_test leader
#####

View File

@ -23,7 +23,7 @@ required_result 0 <<EOF
1
EOF
simple_test master
simple_test leader
#####

View File

@ -23,7 +23,7 @@ required_result 0 <<EOF
0
EOF
simple_test master
simple_test leader
#####

View File

@ -23,7 +23,7 @@ required_result 0 <<EOF
2
EOF
simple_test master
simple_test leader
#####

View File

@ -22,7 +22,7 @@ EOF
required_result 255 <<EOF
EOF
simple_test master
simple_test leader
#####

View File

@ -41,7 +41,7 @@ Failed to detect PNN of the current node.
Is this node part of CTDB cluster?
EOF
simple_test master
simple_test leader
#####

View File

@ -5954,7 +5954,7 @@ static const struct ctdb_cmd {
{ "pnn", control_pnn, false, false,
"show the pnn of the currnet node", NULL },
{ "lvs", control_lvs, false, false,
"show lvs configuration", "master|list|status" },
"show lvs configuration", "leader|list|status" },
{ "setdebug", control_setdebug, false, true,
"set debug level", "ERROR|WARNING|NOTICE|INFO|DEBUG" },
{ "getdebug", control_getdebug, false, true,

View File

@ -23,7 +23,7 @@ usage ()
$0 <option>
<option> is one of:
master Display node number of master node
leader Display node number of leader node
list List node number and private IP address of usable nodes in group
status Show status of all nodes in LVS group
EOF
@ -72,7 +72,7 @@ get_lvs_nodes ()
\#*) continue ;;
esac
case "$_options" in
slave-only|"") : ;;
follower-only|"") : ;;
*) die "${prog}: Invalid options \"${_options}\" in \"$CTDB_LVS_NODES\""
esac
done <<EOF
@ -124,13 +124,13 @@ $nodestatus_X
EOF
}
# Print the PNN of the LVS master node
find_master ()
# Print the PNN of the LVS leader node
find_leader ()
{
get_lvs_nodes || \
die "${prog}: LVS nodes file \"$CTDB_LVS_NODES\" not found"
# $_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
@ -140,8 +140,8 @@ find_master ()
$lvs_nodes
EOF
_master_candidates=$(filter_nodes "$_ms") || return $?
echo "${_master_candidates%% *}"
_leader_candidates=$(filter_nodes "$_ms") || return $?
echo "${_leader_candidates%% *}"
}
# List all usable nodes in the LVS group
@ -197,7 +197,7 @@ prog=$(basename "$0")
cmd="$1"
case "$cmd" in
master) find_master ;;
leader) find_leader ;;
list) nodes_list ;;
status) nodes_status ;;
*) usage ;;