etcd: Rewrite embed etcd implementation
This is a giant cleanup of the etcd code. The earlier version was written when I was less experienced with golang. This is still not perfect, and does contain some races, but at least it's a decent base to start from. The automatic elastic clustering should be considered an experimental feature. If you need a more battle-tested cluster, then you should manage etcd manually and point mgmt at your existing cluster.
This commit is contained in:
@@ -10,7 +10,7 @@ if ! command -v etcdctl >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir /tmp/mgmt/{A..E}
|
||||
#mkdir /tmp/mgmt/{A..E}
|
||||
|
||||
# kill servers on error/exit
|
||||
trap 'pkill -9 mgmt' EXIT
|
||||
@@ -22,7 +22,7 @@ $TIMEOUT "$MGMT" run --hostname h3 --tmp-prefix --no-pgp --seeds http://127.0.0.
|
||||
# wait for everything to converge
|
||||
sleep 30s
|
||||
|
||||
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2379 put /_mgmt/idealClusterSize 3
|
||||
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2379 put /_mgmt/chooser/dynamicsize/idealclustersize 3
|
||||
|
||||
$TIMEOUT "$MGMT" run --hostname h4 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 empty &
|
||||
$TIMEOUT "$MGMT" run --hostname h5 --tmp-prefix --no-pgp --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2387 --server-urls http://127.0.0.1:2388 empty &
|
||||
@@ -32,7 +32,7 @@ sleep 30s
|
||||
|
||||
test "$(ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2379 member list | wc -l)" -eq 3
|
||||
|
||||
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2381 put /_mgmt/idealClusterSize 5
|
||||
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2379 put /_mgmt/chooser/dynamicsize/idealclustersize 5
|
||||
|
||||
# wait for everything to converge
|
||||
sleep 30s
|
||||
27
test/shell/etcd-conflicting-server.sh
Executable file
27
test/shell/etcd-conflicting-server.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
. "$(dirname "$0")/../util.sh"
|
||||
|
||||
# run empty graphs, we're just testing etcd clustering
|
||||
$TIMEOUT "$MGMT" run --no-pgp --tmp-prefix empty &
|
||||
pid1=$!
|
||||
sleep 15s # let it startup
|
||||
|
||||
# run a second one that should conflict because a server is already running...
|
||||
$TIMEOUT "$MGMT" run --no-pgp --tmp-prefix empty &
|
||||
pid2=$!
|
||||
wait $pid2
|
||||
e=$?
|
||||
if [ $e -eq 0 ]; then
|
||||
echo "second mgmt exited successfully when error was expected"
|
||||
exit 1
|
||||
fi
|
||||
if [ $e -ne 1 ]; then
|
||||
echo "second mgmt exited with unexpected error of $e"
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(kill -SIGINT $pid1)& # send ^C to exit 1st mgmt
|
||||
wait $pid1 # get exit status
|
||||
# if pid1 exits because of a timeout, then it blocked, and this is a bug!
|
||||
exit $?
|
||||
35
test/shell/etcd-three-hosts-reversed.sh
Executable file
35
test/shell/etcd-three-hosts-reversed.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
. "$(dirname "$0")/../util.sh"
|
||||
|
||||
# run empty graphs, we're just testing etcd clustering
|
||||
$TIMEOUT "$MGMT" run --hostname h1 --tmp-prefix empty &
|
||||
pid1=$!
|
||||
sleep 15s # let it startup
|
||||
|
||||
$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix empty &
|
||||
pid2=$!
|
||||
sleep 15s
|
||||
|
||||
$TIMEOUT "$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix empty &
|
||||
pid3=$!
|
||||
sleep 15s
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid1)& # send ^C to exit 1st mgmt (reversed!)
|
||||
wait $pid1
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid2)& # send ^C to exit 2nd mgmt
|
||||
wait $pid2
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid3)& # send ^C to exit 3rd mgmt (reversed!)
|
||||
wait $pid3 # get exit status
|
||||
# if pid3 exits because of a timeout, then it blocked, and this is a bug!
|
||||
exit $?
|
||||
24
test/shell/etcd-two-hosts-reversed.sh
Executable file
24
test/shell/etcd-two-hosts-reversed.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
. "$(dirname "$0")/../util.sh"
|
||||
|
||||
# run empty graphs, we're just testing etcd clustering
|
||||
$TIMEOUT "$MGMT" run --hostname h1 --tmp-prefix empty &
|
||||
pid1=$!
|
||||
sleep 15s # let it startup
|
||||
|
||||
$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix empty &
|
||||
pid2=$!
|
||||
sleep 15s
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid1)& # send ^C to exit 1st mgmt! (reverse!)
|
||||
wait $pid1
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid2)& # send ^C to exit 2nd mgmt (reverse!)
|
||||
wait $pid2 # get exit status
|
||||
# if pid2 exits because of a timeout, then it blocked, and this is a bug!
|
||||
exit $?
|
||||
@@ -5,18 +5,58 @@
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
$TIMEOUT "$MGMT" run --hostname h1 --ideal-cluster-size 1 --tmp-prefix --no-pgp lang --lang exchange0.mcl &
|
||||
$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang --lang exchange0.mcl &
|
||||
$TIMEOUT "$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang --lang exchange0.mcl &
|
||||
$TIMEOUT "$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp lang --lang exchange0.mcl &
|
||||
$TIMEOUT "$MGMT" run --hostname h1 --tmp-prefix --no-pgp empty &
|
||||
pid1=$!
|
||||
sleep 10s
|
||||
$TIMEOUT "$MGMT" run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty &
|
||||
pid2=$!
|
||||
sleep 10s
|
||||
$TIMEOUT "$MGMT" run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty &
|
||||
pid3=$!
|
||||
sleep 10s
|
||||
$TIMEOUT "$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty &
|
||||
pid4=$!
|
||||
sleep 10s
|
||||
$TIMEOUT "$MGMT" deploy --no-git --seeds http://127.0.0.1:2379 lang --lang exchange0.mcl
|
||||
|
||||
# kill servers on error/exit
|
||||
trap 'pkill -9 mgmt' EXIT
|
||||
#trap 'pkill -9 mgmt' EXIT
|
||||
|
||||
# wait for everything to converge
|
||||
sleep 10s
|
||||
sleep 15s
|
||||
|
||||
# debug
|
||||
tail /tmp/mgmt/exchange-*
|
||||
|
||||
test "$(cat /tmp/mgmt/exchange-* | grep -c h1)" -eq 4
|
||||
test "$(cat /tmp/mgmt/exchange-* | grep -c h2)" -eq 4
|
||||
test "$(cat /tmp/mgmt/exchange-* | grep -c h3)" -eq 4
|
||||
test "$(cat /tmp/mgmt/exchange-* | grep -c h4)" -eq 4
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid4)& # send ^C to exit mgmt...
|
||||
wait $pid4
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid3)& # send ^C to exit mgmt...
|
||||
wait $pid3
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid2)& # send ^C to exit mgmt...
|
||||
wait $pid2
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
$(sleep 15s && kill -SIGINT $pid1)& # send ^C to exit mgmt...
|
||||
wait $pid1
|
||||
e=$?
|
||||
if [ $e -ne 0 ]; then
|
||||
exit $e
|
||||
fi
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# run this example with these commands
|
||||
# watch -n 0.1 'tail *' # run this in /tmp/mgmt/
|
||||
# time ./mgmt run --hostname h1 --ideal-cluster-size 1 --tmp-prefix --no-pgp lang --lang examples/lang/exchange0.mcl
|
||||
# time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang --lang examples/lang/exchange0.mcl
|
||||
# time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang --lang examples/lang/exchange0.mcl
|
||||
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp lang --lang examples/lang/exchange0.mcl
|
||||
# time ./mgmt run --hostname h1 --tmp-prefix --no-pgp empty
|
||||
# time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty
|
||||
# time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty
|
||||
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty
|
||||
# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang --lang examples/lang/exchange0.mcl
|
||||
|
||||
import "sys"
|
||||
import "world"
|
||||
|
||||
Reference in New Issue
Block a user