Skip to content

Commit

Permalink
scripting (in re: set primary with force)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Nov 7, 2024
1 parent d91c69b commit 7fec115
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 1 deletion.
96 changes: 96 additions & 0 deletions ais/test/scripts/force-join.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

# e.g. usage:
# 1) ais/test/scripts/force-join.sh
# 2) ais/test/scripts/force-join.sh --smap --config --bmd

AISTORE_PATH=$(cd "$(dirname "$0")/../../../"; pwd -P)
# echo $AISTORE_PATH

while (( "$#" )); do
case "${1}" in
--config) config="true"; shift;;
--bmd) bmd="true"; shift;;
--smap) smap="true"; shift;;
*) echo "fatal: unknown argument '${1}'"; exit 1;;
esac
done

make kill clean
./scripts/clean_deploy.sh --target-cnt 6 --proxy-cnt 6 --mountpath-cnt 4 --deployment all --debug --aws --gcp --azure >/dev/null

if ! [ -x "$(command -v ais)" ]; then
echo "Error: ais (CLI) not installed" >&2
exit 1
fi
if ! [ -x "$(command -v aisloader)" ]; then
echo "Error: aisloader not installed" >&2
exit 1
fi

psi=$(ais show cluster proxy | grep "\[P\]" | awk '{print $1}')
pid=${psi:2:8}
echo "designated (destination) primary: $pid"

set -x
sleep 8
set +x

export AIS_ENDPOINT=http://127.0.0.1:11080 ##################################
echo "AIS_ENDPOINT=$AIS_ENDPOINT"

if [[ ${config} == "true" ]]; then
for i in {1..10}; do
ais config cluster lru.enabled true >/dev/null
ais config cluster lru.enabled false >/dev/null
done
echo "victim config:"
ais show cluster config --json | tail -3
fi

if [[ ${bmd} == "true" ]]; then
ais create ais://nnn
for i in {1..10}; do
ais create "ais://nn$i" >/dev/null
done
echo "victim bmd:"
ais show cluster bmd -H
fi


if [[ ${smap} == "true" ]]; then
tsi=$(ais show cluster -H target | awk '{print $1}')
for i in {1..10}; do
ais cluster add-remove-nodes start-maintenance $tsi --yes >/dev/null
ais cluster add-remove-nodes stop-maintenance $tsi --yes >/dev/null
done
echo "victim smap:"
ais show cluster smap --json | tail -4
fi

sleep 1

ais cluster set-primary $pid http://127.0.0.1:8080 --force ##################################

sleep 1
unset -v AIS_ENDPOINT
echo "AIS_ENDPOINT=$AIS_ENDPOINT"
aisloader -bucket=ais://nnn -cleanup=false -numworkers=8 -quiet -pctput=100 -minsize=4K -maxsize=4K --duration 20s

find /tmp/ais_next -type f | grep "mp[1-4].*/1/" | wc -l

if [[ ${config} == "true" ]]; then
echo "resulting config:"
ais show cluster config --json | tail -3
fi
if [[ ${bmd} == "true" ]]; then
echo "resulting bmd:"
ais show cluster bmd --json | tail -3
fi

echo "resulting smap:"
ais show cluster | grep 'Proxies\|Targets'
ais show cluster smap --json | tail -4


ais cluster decommission --yes
8 changes: 7 additions & 1 deletion scripts/clean_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ AIS_BACKEND_PROVIDERS=""
loopback=0
target_cnt=5
proxy_cnt=5
remote_target_cnt=1
remote_proxy_cnt=1
mountpath_cnt=5
deployment="local"
remote_alias="remais"
Expand All @@ -47,6 +49,8 @@ OPTIONS:
--cleanup Cleanup data and metadata from the previous deployments
--deployment Choose which AIS cluster(s) to deploy, one of: 'local', 'remote', 'all' (default: 'local')
--remote-alias Alias to assign to the remote cluster (default: 'remais')
--remote-target-cnt Number of remote cluster (remais) target nodes in the cluster (default: 1)
--remote-proxy-cnt Number of remote proxies/gateways (default: 1)
--aws Build with AWS S3 backend
--gcp Build with Google Cloud Storage backend
--azure Build with Azure Blob Storage backend
Expand Down Expand Up @@ -140,6 +144,8 @@ while (( "$#" )); do
--cleanup) cleanup="true"; shift;;
--transient) RUN_ARGS="$RUN_ARGS -transient"; shift;;
--standby) RUN_ARGS="$RUN_ARGS -standby"; shift;;
--remote-proxy-cnt) remote_proxy_cnt=$2; shift; shift;;
--remote-target-cnt) remote_target_cnt=$2; shift; shift;;
--https)
export AIS_USE_HTTPS="true"
export AIS_SKIP_VERIFY_CRT="true"
Expand Down Expand Up @@ -175,7 +181,7 @@ if [[ ${deployment} == "remote" || ${deployment} == "all" ]]; then
## NOTE: must have the same build tags and, in particular, same backends -
## otherwise, `make deploy` below will rebuild and replace aisnode binary

echo -e "1\n1\n3\n" | DEPLOY_AS_NEXT_TIER="true" AIS_BACKEND_PROVIDERS="${AIS_BACKEND_PROVIDERS}" AIS_AUTHN_ENABLED=false make deploy
echo -e "${remote_target_cnt}\n${remote_proxy_cnt}\n3\n" | DEPLOY_AS_NEXT_TIER="true" AIS_BACKEND_PROVIDERS="${AIS_BACKEND_PROVIDERS}" AIS_AUTHN_ENABLED=false make deploy

# Do not try attach remote cluster if the main cluster did not start.
if [[ ${deployment} == "all" ]]; then
Expand Down

0 comments on commit 7fec115

Please sign in to comment.