зеркало из https://github.com/github/vitess-gh.git
50 строки
1.3 KiB
Bash
Executable File
50 строки
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This is an example script that tears down the vttablet pods started by
|
|
# vttablet-up.sh.
|
|
|
|
set -e
|
|
|
|
script_root=`dirname "${BASH_SOURCE}"`
|
|
source $script_root/env.sh
|
|
|
|
echo "Starting port forwarding to vtctld..."
|
|
start_vtctld_forward
|
|
trap stop_vtctld_forward EXIT
|
|
VTCTLD_ADDR="localhost:$vtctld_forward_port"
|
|
|
|
# Delete the pods for all shards
|
|
CELLS=${CELLS:-'test'}
|
|
keyspace='test_keyspace'
|
|
SHARDS=${SHARDS:-'0'}
|
|
TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-5}
|
|
UID_BASE=${UID_BASE:-100}
|
|
VITESS_NAME=${VITESS_NAME:-'default'}
|
|
|
|
num_shards=`echo $SHARDS | tr "," " " | wc -w`
|
|
uid_base=$UID_BASE
|
|
cells=`echo $CELLS | tr ',' ' '`
|
|
num_cells=`echo $cells | wc -w`
|
|
|
|
for shard in `seq 1 $num_shards`; do
|
|
[[ $num_cells -gt 1 ]] && cell_index=100000000 || cell_index=0
|
|
for cell in $cells; do
|
|
for uid_index in `seq 0 $(($TABLETS_PER_SHARD-1))`; do
|
|
uid=$[$uid_base + $uid_index + $cell_index]
|
|
printf -v alias '%s-%010d' $cell $uid
|
|
|
|
if [ -n "$VTCTLD_ADDR" ]; then
|
|
set +e
|
|
echo "Removing tablet $alias from Vitess topology..."
|
|
vtctlclient -server $VTCTLD_ADDR DeleteTablet -allow_master -skip_rebuild $alias
|
|
set -e
|
|
fi
|
|
|
|
echo "Deleting pod for tablet $alias..."
|
|
$KUBECTL delete pod vttablet-$uid --namespace=$VITESS_NAME
|
|
done
|
|
let cell_index=cell_index+100000000
|
|
done
|
|
let uid_base=uid_base+100
|
|
done
|