mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ctdb-tools: Change ctdb CLI to have a single "lvs" command
This simply calls out to the wrapper, so that commands are changed as follows: ctdb lvsmaster -> ctdb lvs master ctdb lvs -> ctdb lvs list This provides a simple, extensible interface and means that "ctdb lvs status" is also available. Unit tests are streamlined so that there is a single test for each CTDB state. Each test does "master", "list" and "status" sub-tests. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
9543e35557
commit
e3a7178511
@ -723,38 +723,36 @@ MonitorInterval = 15
|
||||
</refsect2>
|
||||
|
||||
<refsect2>
|
||||
<title>lvsmaster</title>
|
||||
<title>lvs {master|list|status}</title>
|
||||
<para>
|
||||
This command shows which node is currently the LVSMASTER. The
|
||||
LVSMASTER is the node in the cluster which drives the LVS system and
|
||||
which receives all incoming traffic from clients.
|
||||
</para>
|
||||
<para>
|
||||
LVS is the mode where the entire CTDB/Samba cluster uses a single
|
||||
ip address for the entire cluster. In this mode all clients connect to
|
||||
one specific node which will then multiplex/loadbalance the clients
|
||||
evenly onto the other nodes in the cluster. This is an alternative to using
|
||||
public ip addresses. See the manpage for ctdbd for more information
|
||||
about LVS.
|
||||
</para>
|
||||
</refsect2>
|
||||
|
||||
<refsect2>
|
||||
<title>lvs</title>
|
||||
<para>
|
||||
This command shows which nodes in the cluster are currently active in the
|
||||
LVS configuration. I.e. which nodes we are currently loadbalancing
|
||||
the single ip address across.
|
||||
This command shows different aspects of LVS status. For an
|
||||
overview of CTDB's LVS functionality please see the
|
||||
<citetitle>LVS</citetitle> section in
|
||||
<citerefentry><refentrytitle>ctdb</refentrytitle>
|
||||
<manvolnum>7</manvolnum></citerefentry>.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>master</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Shows the PNN of the current LVS master node.
|
||||
</para>
|
||||
<para>
|
||||
LVS will by default only loadbalance across those nodes that are both
|
||||
LVS capable and also HEALTHY. Except if all nodes are UNHEALTHY in which
|
||||
case LVS will loadbalance across all UNHEALTHY nodes as well.
|
||||
LVS will never use nodes that are DISCONNECTED, STOPPED, BANNED or
|
||||
DISABLED.
|
||||
Example output:
|
||||
</para>
|
||||
|
||||
<screen>
|
||||
Node 2 is LVS master
|
||||
</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>list</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Lists the currently usable LVS nodes.
|
||||
</para>
|
||||
<para>
|
||||
Example output:
|
||||
</para>
|
||||
@ -762,6 +760,26 @@ MonitorInterval = 15
|
||||
2:10.0.0.13
|
||||
3:10.0.0.14
|
||||
</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>status</term>
|
||||
<listitem>
|
||||
<para>
|
||||
List the nodes in the current LVS group and their status.
|
||||
</para>
|
||||
<para>
|
||||
Example output:
|
||||
</para>
|
||||
<screen>
|
||||
pnn:0 10.0.0.11 UNHEALTHY (THIS NODE)
|
||||
pnn:1 10.0.0.12 UNHEALTHY
|
||||
pnn:2 10.0.0.13 OK
|
||||
pnn:3 10.0.0.14 OK
|
||||
</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
</refsect2>
|
||||
|
||||
|
@ -7,10 +7,7 @@ define_test "3 nodes, no LVS, all ok"
|
||||
setup_lvs <<EOF
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x0 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
@ -26,4 +23,32 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 255 <<EOF
|
||||
There is no LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
@ -10,13 +10,7 @@ setup_lvs <<EOF
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x0 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
@ -32,4 +26,38 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
pnn:0 192.168.20.41 OK (THIS NODE)
|
||||
pnn:1 192.168.20.42 OK
|
||||
pnn:2 192.168.20.43 OK
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
@ -9,12 +9,7 @@ setup_lvs <<EOF
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x0 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
@ -30,4 +25,35 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
pnn:0 192.168.20.41 OK (THIS NODE)
|
||||
pnn:2 192.168.20.43 OK
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
@ -10,11 +10,7 @@ setup_lvs <<EOF
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 1 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x2 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
@ -30,4 +26,37 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 1 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
pnn:0 192.168.20.41 UNHEALTHY (THIS NODE)
|
||||
pnn:1 192.168.20.42 OK
|
||||
pnn:2 192.168.20.43 OK
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
@ -10,11 +10,7 @@ setup_lvs <<EOF
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x2 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x2
|
||||
@ -30,4 +26,38 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
pnn:0 192.168.20.41 UNHEALTHY (THIS NODE)
|
||||
pnn:1 192.168.20.42 UNHEALTHY
|
||||
pnn:2 192.168.20.43 UNHEALTHY
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
@ -10,11 +10,7 @@ setup_lvs <<EOF
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 2 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x4 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x4
|
||||
@ -30,4 +26,36 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 2 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
2:192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
pnn:0 192.168.20.41 DISABLED (THIS NODE)
|
||||
pnn:1 192.168.20.42 DISABLED
|
||||
pnn:2 192.168.20.43 UNHEALTHY
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
@ -10,11 +10,7 @@ setup_lvs <<EOF
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 255 <<EOF
|
||||
There is no LVS master
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x4 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x4
|
||||
@ -30,4 +26,35 @@ VNNMAP
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 255 <<EOF
|
||||
There is no LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
pnn:0 192.168.20.41 DISABLED (THIS NODE)
|
||||
pnn:1 192.168.20.42 DISABLED
|
||||
pnn:2 192.168.20.43 DISABLED
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
66
ctdb/tests/tool/stubby.lvs.008.sh
Executable file
66
ctdb/tests/tool/stubby.lvs.008.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "3 nodes, no LVS, current disconnected"
|
||||
|
||||
setup_lvs <<EOF
|
||||
EOF
|
||||
|
||||
ctdb_state="\
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x1 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
2 192.168.20.43 0x0
|
||||
|
||||
IFACES
|
||||
:Name:LinkStatus:References:
|
||||
:eth2:1:2:
|
||||
:eth1:1:4:
|
||||
|
||||
VNNMAP
|
||||
654321
|
||||
0
|
||||
1
|
||||
2
|
||||
"
|
||||
|
||||
#####
|
||||
|
||||
required_result 10 <<EOF
|
||||
${TEST_DATE_STAMP}Unable to get nodemap from local node
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 10 <<EOF
|
||||
${TEST_DATE_STAMP}Unable to get nodemap from local node
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 10 <<EOF
|
||||
${TEST_DATE_STAMP}Unable to get nodemap from local node
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
||||
|
||||
#####
|
||||
|
||||
required_result 10 <<EOF
|
||||
${TEST_DATE_STAMP}Unable to get nodemap from local node
|
||||
EOF
|
||||
|
||||
simple_test status <<EOF
|
||||
$ctdb_state
|
||||
EOF
|
@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "3 nodes, no LVS, all ok"
|
||||
|
||||
setup_lvs <<EOF
|
||||
EOF
|
||||
|
||||
required_result 255 <<EOF
|
||||
There is no LVS master
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x0 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
2 192.168.20.43 0x0
|
||||
|
||||
IFACES
|
||||
:Name:LinkStatus:References:
|
||||
:eth2:1:2:
|
||||
:eth1:1:4:
|
||||
|
||||
VNNMAP
|
||||
654321
|
||||
0
|
||||
1
|
||||
2
|
||||
EOF
|
@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "3 nodes, current disconnected"
|
||||
|
||||
setup_lvs <<EOF
|
||||
EOF
|
||||
|
||||
required_result 10 <<EOF
|
||||
${TEST_DATE_STAMP}Unable to get nodemap from local node
|
||||
EOF
|
||||
|
||||
simple_test -Y <<EOF
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x1 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
2 192.168.20.43 0x0
|
||||
|
||||
IFACES
|
||||
:Name:LinkStatus:References:
|
||||
:eth2:1:2:
|
||||
:eth1:1:4:
|
||||
|
||||
VNNMAP
|
||||
654321
|
||||
0
|
||||
1
|
||||
2
|
||||
EOF
|
@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "3 nodes, all LVS, all ok"
|
||||
|
||||
setup_lvs <<EOF
|
||||
192.168.20.41
|
||||
192.168.20.42
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
EOF
|
||||
|
||||
simple_test <<EOF
|
||||
NODEMAP
|
||||
0 192.168.20.41 0x0 CURRENT RECMASTER
|
||||
1 192.168.20.42 0x0
|
||||
2 192.168.20.43 0x0
|
||||
|
||||
IFACES
|
||||
:Name:LinkStatus:References:
|
||||
:eth2:1:2:
|
||||
:eth1:1:4:
|
||||
|
||||
VNNMAP
|
||||
654321
|
||||
0
|
||||
1
|
||||
2
|
||||
EOF
|
@ -3118,13 +3118,13 @@ static int control_getcapabilities(struct ctdb_context *ctdb, int argc, const ch
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* display lvs configuration */
|
||||
/* Display LVS status */
|
||||
static int control_lvs(struct ctdb_context *ctdb,
|
||||
int argc, const char **argv)
|
||||
{
|
||||
static char prog[PATH_MAX+1] = "";
|
||||
|
||||
if (argc != 0) {
|
||||
if (argc != 1) {
|
||||
usage();
|
||||
}
|
||||
|
||||
@ -3135,31 +3135,7 @@ static int control_lvs(struct ctdb_context *ctdb,
|
||||
exit(1);
|
||||
}
|
||||
|
||||
execl(prog, prog, "list", NULL);
|
||||
|
||||
DEBUG(DEBUG_ERR,
|
||||
("Unable to run LVS helper %s\n", strerror(errno)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* display who the lvs is */
|
||||
static int control_lvsmaster(struct ctdb_context *ctdb,
|
||||
int argc, const char **argv)
|
||||
{
|
||||
static char prog[PATH_MAX+1] = "";
|
||||
|
||||
if (argc != 0) {
|
||||
usage();
|
||||
}
|
||||
|
||||
if (!ctdb_set_helper("LVS helper", prog, sizeof(prog),
|
||||
"CTDB_LVS_HELPER", CTDB_HELPER_BINDIR,
|
||||
"ctdb_lvs")) {
|
||||
DEBUG(DEBUG_ERR, ("Unable to set LVS helper\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
execl(prog, prog, "master", NULL);
|
||||
execl(prog, prog, argv[0], NULL);
|
||||
|
||||
DEBUG(DEBUG_ERR,
|
||||
("Unable to run LVS helper %s\n", strerror(errno)));
|
||||
@ -5926,8 +5902,7 @@ static const struct {
|
||||
{ "getmonmode", control_getmonmode, true, false, "show monitoring mode" },
|
||||
{ "getcapabilities", control_getcapabilities, true, false, "show node capabilities" },
|
||||
{ "pnn", control_pnn, true, false, "show the pnn of the currnet node" },
|
||||
{ "lvs", control_lvs, false, true, "show lvs configuration" },
|
||||
{ "lvsmaster", control_lvsmaster, false, true, "show which node is the lvs master" },
|
||||
{ "lvs", control_lvs, false, true, "show lvs configuration", "[master|list|status]" },
|
||||
{ "disablemonitor", control_disable_monmode,true, false, "set monitoring mode to DISABLE" },
|
||||
{ "enablemonitor", control_enable_monmode, true, false, "set monitoring mode to ACTIVE" },
|
||||
{ "setdebug", control_setdebug, true, false, "set debug level", "<EMERG|ALERT|CRIT|ERR|WARNING|NOTICE|INFO|DEBUG>" },
|
||||
|
Loading…
Reference in New Issue
Block a user