2014-10-31 00:34:50 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This is an example script that tears down the vttablet pods started by
|
2015-01-30 05:15:32 +03:00
|
|
|
# vttablet-up.sh.
|
|
|
|
|
2015-02-03 02:30:41 +03:00
|
|
|
set -e
|
|
|
|
|
2015-01-30 05:15:32 +03:00
|
|
|
script_root=`dirname "${BASH_SOURCE}"`
|
|
|
|
source $script_root/env.sh
|
2014-10-31 00:34:50 +03:00
|
|
|
|
2015-06-30 00:52:43 +03:00
|
|
|
server=$(get_vtctld_addr)
|
|
|
|
|
2015-02-21 06:35:50 +03:00
|
|
|
# Delete the pods for all shards
|
2015-07-22 21:33:26 +03:00
|
|
|
CELLS=${CELLS:-'test'}
|
2014-12-19 11:19:26 +03:00
|
|
|
keyspace='test_keyspace'
|
2015-02-21 06:35:50 +03:00
|
|
|
SHARDS=${SHARDS:-'0'}
|
2015-06-28 01:10:56 +03:00
|
|
|
TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-5}
|
|
|
|
UID_BASE=${UID_BASE:-100}
|
|
|
|
|
2015-02-21 06:35:50 +03:00
|
|
|
num_shards=`echo $SHARDS | tr "," " " | wc -w`
|
2015-06-28 01:10:56 +03:00
|
|
|
uid_base=$UID_BASE
|
2014-10-31 00:34:50 +03:00
|
|
|
|
2015-02-21 06:35:50 +03:00
|
|
|
for shard in `seq 1 $num_shards`; do
|
2015-07-23 01:53:05 +03:00
|
|
|
cell_index=0
|
2015-07-22 21:33:26 +03:00
|
|
|
for cell in `echo $CELLS | tr "," " "`; 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 "$server" ]; then
|
|
|
|
echo "Removing tablet $alias from Vitess topology..."
|
|
|
|
vtctlclient -server $server ScrapTablet -force $alias
|
|
|
|
vtctlclient -server $server DeleteTablet $alias
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Deleting pod for tablet $alias..."
|
2015-07-25 02:25:58 +03:00
|
|
|
$KUBECTL delete pod vttablet-$uid
|
2015-07-22 21:33:26 +03:00
|
|
|
done
|
|
|
|
let cell_index=cell_index+100000000
|
2015-02-20 23:33:20 +03:00
|
|
|
done
|
2015-06-28 01:10:56 +03:00
|
|
|
let uid_base=uid_base+100
|
2014-10-31 00:34:50 +03:00
|
|
|
done
|