Skip to content

Commit

Permalink
scripts: Fix clean_deploy panic and implement empty value checking
Browse files Browse the repository at this point in the history
Signed-off-by: Soham Manoli <[email protected]>
  • Loading branch information
msoham123 committed Jun 5, 2024
1 parent 5c3fa22 commit 8f7c3ee
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 21 deletions.
7 changes: 4 additions & 3 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ $ make help

### Clean deploy

```
./clean_deploy.sh [--target-cnt TARGET_CNT] [--proxy-cnt PROXY_CNT] [--mountpath-cnt MOUNTPATH_CNT] [--https] [--deployment local|remote|all] [--remote-alias REMOTE_ALIAS] [--PROVIDER ...] [--debug PKG=LOG_LEVEL[,PKG=LOG_LEVEL]] [--loopback SIZE]
```console
./clean_deploy.sh [--target-cnt TARGET_CNT] [--proxy-cnt PROXY_CNT] [--mountpath-cnt MOUNTPATH_CNT] [--https] [--deployment local|remote|all] [--remote-alias REMOTE_ALIAS] [--PROVIDER ...] [--debug PKG=LOG_LEVEL[,PKG=LOG_LEVEL]] [--loopback SIZE] [--cleanup] [--dir]
[--override_backends] [--standby] [--transient] [--debug]
```

Performs cleanup and then deploys a new instance of an AIS cluster.
Deploys a new instance of an AIS cluster after killing any current instances.
To make it even more convenient, consider setting up an alias:

```bash
Expand Down
79 changes: 61 additions & 18 deletions scripts/clean_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,77 @@ OPTIONS:
# NOTE: `AIS_USE_HTTPS` and other system environment variables are listed in the `env` package:
# https://github.com/NVIDIA/aistore/blob/main/api/env/README.md

export MODE="debug"

# NOTE: additional `aisnode` command-line (run `aisnode --help`)
export RUN_ARGS=""

function validate_arg {
local arg_name=$1
local arg_value=$2
if [ -z "$arg_value" ] || [[ "$arg_value" == -* ]]; then
echo "Error: ${arg_name} option requires a non-empty value."
exit 1
fi
}

while (( "$#" )); do
case "${1}" in
-h|--help) echo -n "${usage}"; exit;;

--aws) aws_provider="y"; shift;;
--azure) azure_provider="y"; shift;;
--gcp) gcp_provider="y"; shift;;
--loopback) loopback=$2; shift; shift;;
--dir) root_dir=$2; shift; shift;;
--deployment) deployment=$2; shift; shift;;
--remote-alias) remote_alias=$2; shift; shift;;
--target-cnt) target_cnt=$2; shift; shift;;
--proxy-cnt) proxy_cnt=$2; shift; shift;;
--mountpath-cnt) mountpath_cnt=$2; shift; shift;;
--loopback) loopback=$2;

# if loopback is empty stop and notify
validate_arg $1 $2

shift 2;;
--dir) root_dir=$2;

# if dir is empty stop and notify
if [ -z "$root_dir" ] || [[ "$root_dir" == -* ]]; then
echo "Error: --dir option requires a non-empty value."
exit 1
fi

shift 2;;
--deployment) deployment=$2;

# if deployment is empty stop and notify
validate_arg $1 $2

# if deployment is invalid stop and notify
if [[ "$deployment" != "local" && "$deployment" != "remote" && "$deployment" != "all" ]]; then
echo "fatal: unknown --deployment argument value '${deployment}' (expected one of: 'local', 'remote', 'all')"
exit 1
fi

shift 2;;
--remote-alias) remote_alias=$2;

# if remote-alias is empty stop and notify
validate_arg $1 $2

shift 2;;
--target-cnt) target_cnt=$2;

# if the target-cnt is empty stop and notify
validate_arg $1 $2

shift 2;;
--proxy-cnt) proxy_cnt=$2;

# if the proxy-cnt is empty stop and notify
validate_arg $1 $2

shift 2;;
--mountpath-cnt) mountpath_cnt=$2;

# if the mountpath-cnt is empty stop and notify
validate_arg $1 $2

shift 2;;
--debug) export MODE="debug"; shift;;
--cleanup) cleanup="true"; shift;;
--transient) RUN_ARGS="$RUN_ARGS -transient"; shift;;
--standby) RUN_ARGS="$RUN_ARGS -standby"; shift;;
Expand All @@ -99,15 +151,6 @@ while (( "$#" )); do
esac
done

case "${deployment}" in
local|remote|all)
;;
*)
echo "fatal: unknown --deployment argument value '${deployment}' (expected one of: 'local', 'remote', 'all')"
exit 1
;;
esac

pushd "${root_dir}" 1>/dev/null

make kill
Expand Down

0 comments on commit 8f7c3ee

Please sign in to comment.