You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by wa...@apache.org on 2023/03/14 02:53:49 UTC
[incubator-pegasus] branch master updated: chore(script): support specifying config file while downgrading node by shell (#1369)
This is an automated email from the ASF dual-hosted git repository.
wangdan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new 7b40abcdd chore(script): support specifying config file while downgrading node by shell (#1369)
7b40abcdd is described below
commit 7b40abcdd1afe97d965c81e33348aae6ad76a9a3
Author: WHBANG <38...@users.noreply.github.com>
AuthorDate: Tue Mar 14 10:53:42 2023 +0800
chore(script): support specifying config file while downgrading node by shell (#1369)
https://github.com/apache/incubator-pegasus/issues/1368
While we've supported using default config file for the shell to downgrading node, sometimes
we have to specify another config file in different path for it.
---
run.sh | 25 ++++++++++++++++++++----
scripts/downgrade_node.sh | 50 +++++++++++++++++++++++++++++++++++------------
2 files changed, 59 insertions(+), 16 deletions(-)
diff --git a/run.sh b/run.sh
index 3adb6b106..7bbe4b356 100755
--- a/run.sh
+++ b/run.sh
@@ -1636,7 +1636,10 @@ function run_shell()
./pegasus_shell ${CONFIG} $CLUSTER_NAME
# because pegasus shell will catch 'Ctrl-C' signal, so the following commands will be executed
# even user inputs 'Ctrl-C', so that the temporary config file will be cleared when exit shell.
- rm -f ${CONFIG}
+ # however, if it is the specified config file, do not delete it.
+ if [ ${CONFIG_SPECIFIED} -eq 0 ]; then
+ rm -f ${CONFIG}
+ fi
}
#####################
@@ -1741,6 +1744,7 @@ function usage_downgrade_node()
echo "Options for subcommand 'downgrade_node':"
echo " -h|--help print the help info"
echo " -c|--cluster <str> cluster meta lists"
+ echo " -f|--config <str> config file path"
echo " -n|--node <str> the node to downgrade replicas, should be ip:port"
echo " -a|--app <str> the app to downgrade replicas, if not set, means downgrade all apps"
echo " -t|--type <str> type: test or run, default is test"
@@ -1749,6 +1753,7 @@ function usage_downgrade_node()
function run_downgrade_node()
{
CLUSTER=""
+ CONFIG=""
NODE=""
APP="*"
TYPE="test"
@@ -1763,6 +1768,10 @@ function run_downgrade_node()
CLUSTER="$2"
shift
;;
+ -f|--config)
+ CONFIG="$2"
+ shift
+ ;;
-n|--node)
NODE="$2"
shift
@@ -1785,7 +1794,7 @@ function run_downgrade_node()
shift
done
- if [ "$CLUSTER" == "" ]; then
+ if [ "$CLUSTER" == "" -a "$CONFIG" == "" ]; then
echo "ERROR: no cluster specified"
echo
usage_downgrade_node
@@ -1806,14 +1815,22 @@ function run_downgrade_node()
exit 1
fi
- echo "CLUSTER=$CLUSTER"
+ if [ "$CLUSTER" != "" ]; then
+ echo "CLUSTER=$CLUSTER"
+ else
+ echo "CONFIG=$CONFIG"
+ fi
echo "NODE=$NODE"
echo "APP=$APP"
echo "TYPE=$TYPE"
echo
cd ${ROOT}
echo "------------------------------"
- ./scripts/downgrade_node.sh $CLUSTER $NODE "$APP" $TYPE
+ if [ "$CLUSTER" != "" ]; then
+ ./scripts/downgrade_node.sh $CLUSTER $NODE "$APP" $TYPE
+ else
+ ./scripts/downgrade_node.sh $CONFIG $NODE "$APP" $TYPE -f
+ fi
echo "------------------------------"
echo
if [ "$TYPE" == "test" ]; then
diff --git a/scripts/downgrade_node.sh b/scripts/downgrade_node.sh
index a8e80892b..3a405876c 100755
--- a/scripts/downgrade_node.sh
+++ b/scripts/downgrade_node.sh
@@ -20,11 +20,18 @@ set -e
PID=$$
-if [ $# -ne 4 ]
-then
+function usage()
+{
echo "This tool is for downgrading replicas of specified node."
- echo "USAGE: $0 <cluster-meta-list> <node> <app-name> <run|test>"
- echo " app-name = * means migrate all apps"
+ echo
+ echo "USAGE1: $0 <cluster-meta-list> <node> <app-name> <run|test>"
+ echo "USAGE2: $0 <shell-config-path> <node> <app-name> <run|test> -f"
+ echo "app-name = * means downgrade all apps"
+}
+
+if [ $# -ne 4 -a $# -ne 5 ]
+then
+ usage
exit 1
fi
@@ -32,15 +39,23 @@ pwd="$( cd "$( dirname "$0" )" && pwd )"
shell_dir="$( cd $pwd/.. && pwd )"
cd $shell_dir
-cluster=$1
+if [ $# -eq 4 ]; then
+ cluster=$1
+elif [ "$5" == "-f" ]; then
+ config=$1
+else
+ usage
+ echo "ERROR: invalid option: $5"
+ exit 1
+fi
node=$2
app_name=$3
type=$4
if [ "$type" != "run" -a "$type" != "test" ]
then
+ usage
echo "ERROR: invalid type: $type"
- echo "USAGE: $0 <cluster-meta-list> <node> <app-name> <run|test>"
exit 1
fi
@@ -48,9 +63,13 @@ echo "UID=$UID"
echo "PID=$PID"
echo
-echo "set_meta_level steady" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.set_meta_level
-
-echo ls | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.ls
+if [ [ "$cluster" != "" ]; then
+ echo "set_meta_level steady" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.set_meta_level
+ echo ls | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.ls
+else
+ echo "set_meta_level steady" | ./run.sh shell --config $config &>/tmp/$UID.$PID.pegasus.set_meta_level
+ echo ls | ./run.sh shell --config $config &>/tmp/$UID.$PID.pegasus.ls
+fi
while read app_line
do
@@ -64,8 +83,11 @@ do
continue
fi
- echo "app $app -d" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.app.$app
-
+ if [ "$cluster" != "" ]; then
+ echo "app $app -d" | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.app.$app
+ else
+ echo "app $app -d" | ./run.sh shell --config $config &>/tmp/$UID.$PID.pegasus.app.$app
+ fi
while read line
do
sec=`echo $line | awk '{print $5}' | grep -o '\[.*\]' | grep -o '[0-9.:,]*'`
@@ -95,7 +117,11 @@ do
if [ "$type" = "run" ]
then
cat /tmp/$UID.$PID.pegasus.cmd.$app
- cat /tmp/$UID.$PID.pegasus.cmd.$app | ./run.sh shell --cluster $cluster 2>/dev/null
+ if [ "$cluster" != "" ]; then
+ cat /tmp/$UID.$PID.pegasus.cmd.$app | ./run.sh shell --cluster $cluster 2>/dev/null
+ else
+ cat /tmp/$UID.$PID.pegasus.cmd.$app | ./run.sh shell --config $config 2>/dev/null
+ fi
echo
echo
else
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org