github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/scripts/clean_deploy.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 function retry { 6 local n=1 7 local max=5 8 local delay=5 9 while true; do 10 "$@" && break || { 11 if [[ $n -lt $max ]]; then 12 ((n++)) 13 echo "Command failed. Attempt $n/$max:" 14 sleep $delay; 15 else 16 echo "The command has failed after $n attempts." >&2 17 exit 1 18 fi 19 } 20 done 21 } 22 23 root_dir="$(cd "$(dirname "$0")/../"; pwd -P)" ## NOTE: this assumes `clean_deploy.sh` itself is one level below 24 25 # Default values 26 aws_provider="n" 27 azure_provider="n" 28 gcp_provider="n" 29 loopback=0 30 target_cnt=5 31 proxy_cnt=5 32 mountpath_cnt=5 33 deployment="local" 34 remote_alias="rmtais" 35 cleanup="false" 36 37 usage="NAME: 38 $(basename "$0") - locally deploy AIS clusters for development 39 40 USAGE: 41 ./clean_deploy.sh [options...] 42 43 OPTIONS: 44 --target-cnt Number of target nodes in the cluster (default: 5) 45 --proxy-cnt Number of proxies/gateways (default: 5) 46 --mountpath-cnt Number of mountpaths (default: 5) 47 --cleanup Cleanup data and metadata from the previous deployments 48 --deployment Choose which AIS cluster(s) to deploy, one of: 'local', 'remote', 'all' (default: 'local') 49 --remote-alias Alias to assign to the remote cluster (default: 'rmtais') 50 --aws Support AWS S3 backend (i.e., build \`aisnode\` executable with AWS S3 SDK) 51 --gcp Support Google Cloud Platform (i.e., build \`aisnode\` with libraries to access GCP) 52 --azure Support Azure Cloud (experimental) 53 --loopback Loopback device size, e.g. 10G, 100M (default: 0). Zero size means: no loopbacks. 54 --dir The root directory of the aistore repository 55 --https Use HTTPS 56 --override_backends Configure remote backends at deployment time (override previously stored backend configuration) 57 --standby When starting up, do not join cluster - wait instead for admin request (advanced usage, target-only) 58 --transient Do not store config changes, keep all the updates in memory 59 -h, --help Show this help text 60 " 61 62 # NOTE: `AIS_USE_HTTPS` and other system environment variables are listed in the `env` package: 63 # https://github.com/NVIDIA/aistore/blob/main/api/env/README.md 64 65 export MODE="debug" 66 67 # NOTE: additional `aisnode` command-line (run `aisnode --help`) 68 export RUN_ARGS="" 69 70 while (( "$#" )); do 71 case "${1}" in 72 -h|--help) echo -n "${usage}"; exit;; 73 74 --aws) aws_provider="y"; shift;; 75 --azure) azure_provider="y"; shift;; 76 --gcp) gcp_provider="y"; shift;; 77 --loopback) loopback=$2; shift; shift;; 78 --dir) root_dir=$2; shift; shift;; 79 --deployment) deployment=$2; shift; shift;; 80 --remote-alias) remote_alias=$2; shift; shift;; 81 --target-cnt) target_cnt=$2; shift; shift;; 82 --proxy-cnt) proxy_cnt=$2; shift; shift;; 83 --mountpath-cnt) mountpath_cnt=$2; shift; shift;; 84 --cleanup) cleanup="true"; shift;; 85 --transient) RUN_ARGS="$RUN_ARGS -transient"; shift;; 86 --standby) RUN_ARGS="$RUN_ARGS -standby"; shift;; 87 --override_backends) RUN_ARGS="$RUN_ARGS -override_backends"; shift;; 88 --override-backends) RUN_ARGS="$RUN_ARGS -override_backends"; shift;; 89 --https) 90 export AIS_USE_HTTPS="true" 91 export AIS_SKIP_VERIFY_CRT="true" 92 export AIS_SERVER_CRT="${AIS_SERVER_CRT:$HOME/localhost.crt}" 93 export AIS_SERVER_KEY="${AIS_SERVER_KEY:$HOME/localhost.key}" 94 shift 95 ;; 96 -*) RUN_ARGS="$RUN_ARGS ${1}"; shift;; ## NOTE: catch-all here assumes that everything that falls through the switch is binary 97 98 *) echo "fatal: unknown argument '${1}'"; exit 1;; 99 esac 100 done 101 102 case "${deployment}" in 103 local|remote|all) 104 ;; 105 *) 106 echo "fatal: unknown --deployment argument value '${deployment}' (expected one of: 'local', 'remote', 'all')" 107 exit 1 108 ;; 109 esac 110 111 pushd "${root_dir}" 1>/dev/null 112 113 make kill 114 if [[ ${cleanup} == "true" ]]; then 115 make clean 116 fi 117 118 if [[ ${deployment} == "local" || ${deployment} == "all" ]]; then 119 echo -e "${target_cnt}\n${proxy_cnt}\n${mountpath_cnt}\n${aws_provider}\n${gcp_provider}\n${azure_provider}\n${loopback}\n" |\ 120 make deploy "RUN_ARGS=${RUN_ARGS}" 121 fi 122 123 make -j8 authn aisloader cli 1>/dev/null # Build binaries in parallel 124 125 if [[ ${deployment} == "remote" || ${deployment} == "all" ]]; then 126 if [[ ${deployment} == "all" ]]; then 127 echo -e "\n*** Remote cluster ***" 128 fi 129 echo -e "1\n1\n3\n${aws_provider}\n${gcp_provider}\n${azure_provider}\n${loopback}\n" | DEPLOY_AS_NEXT_TIER="true" AIS_AUTHN_ENABLED=false make deploy 130 131 # Do not try attach remote cluster if the main cluster did not start. 132 if [[ ${deployment} == "all" ]]; then 133 tier_endpoint="http://127.0.0.1:11080" 134 if [[ -n ${AIS_USE_HTTPS} ]]; then 135 tier_endpoint="https://127.0.0.1:11080" 136 fi 137 sleep 5 138 if [[ ${AIS_AUTHN_ENABLED} == "true" ]]; then 139 tokenfile=$(mktemp -q /tmp/ais.auth.token.XXXXXX) 140 ais auth login admin -p admin -f ${tokenfile} 141 export AIS_AUTHN_TOKEN_FILE=${tokenfile} 142 fi 143 retry ais cluster remote-attach "${remote_alias}=${tier_endpoint}" 144 fi 145 fi 146 147 popd 1>/dev/null