Skip to content

Commit

Permalink
fix(script): oprimizations for pegasus_rolling_update.sh (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyifan27 authored Apr 28, 2021
1 parent 68ee2a2 commit ecfa75b
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions scripts/pegasus_rolling_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
PID=$$

if [ $# -le 3 ]; then
echo "USAGE: $0 <cluster-name> <cluster-meta-list> <type> <start_task_id>"
echo "USAGE: $0 <cluster-name> <cluster-meta-list> <type> <start_task_id> "
"<rebalance_cluster_after_rolling>(default false) <rebalance_only_move_primary>(default true)"
echo
echo "The type may be 'one' or 'all':"
echo " - one: rolling update only one task of replica server."
Expand All @@ -48,6 +49,18 @@ if [ "$type" != "one" -a "$type" != "all" ]; then
exit 1
fi

if [ -z $5 ]; then
rebalance_cluster_after_rolling=false
else
rebalance_cluster_after_rolling=$5
fi

if [ -z $6 ]; then
rebalance_only_move_primary=true
else
rebalance_only_move_primary=$6
fi

pwd="$( cd "$( dirname "$0" )" && pwd )"
shell_dir="$( cd $pwd/.. && pwd )"
cd $shell_dir
Expand Down Expand Up @@ -222,14 +235,6 @@ do

echo "remote_command -l $node flush-log" | ./run.sh shell --cluster $meta_list &>/dev/null

echo "Set lb.add_secondary_max_count_for_one_node to 100..."
echo "remote_command -l $pmeta meta.lb.add_secondary_max_count_for_one_node 100" | ./run.sh shell --cluster $meta_list &>/tmp/$UID.$PID.pegasus.rolling_update.add_secondary_max_count_for_one_node
set_ok=`grep OK /tmp/$UID.$PID.pegasus.rolling_update.add_secondary_max_count_for_one_node | wc -l`
if [ $set_ok -ne 1 ]; then
echo "ERROR: set lb.add_secondary_max_count_for_one_node to 100 failed"
exit 1
fi

echo "Rolling update by minos..."
minos_rolling_update $cluster replica $task_id
echo "Rolling update by minos done."
Expand All @@ -250,6 +255,14 @@ do
echo
sleep 1

echo "Set lb.add_secondary_max_count_for_one_node to 100..."
echo "remote_command -l $pmeta meta.lb.add_secondary_max_count_for_one_node 100" | ./run.sh shell --cluster $meta_list &>/tmp/$UID.$PID.pegasus.rolling_update.add_secondary_max_count_for_one_node
set_ok=`grep OK /tmp/$UID.$PID.pegasus.rolling_update.add_secondary_max_count_for_one_node | wc -l`
if [ $set_ok -ne 1 ]; then
echo "ERROR: set lb.add_secondary_max_count_for_one_node to 100 failed"
exit 1
fi

echo "Wait cluster to become healthy..."
while true
do
Expand Down Expand Up @@ -294,8 +307,11 @@ if [ "$type" = "all" ]; then
minos_rolling_update $cluster collector
echo "Rolling update collectors done."
echo
fi

./scripts/pegasus_rebalance_cluster.sh $cluster $meta_list
if [ "$rebalance_cluster_after_rolling" == "true" ]; then
echo "Start to rebalance cluster..."
./scripts/pegasus_rebalance_cluster.sh $cluster $meta_list $rebalance_only_move_primary
fi

echo "Finish time: `date`"
Expand Down

0 comments on commit ecfa75b

Please sign in to comment.