solana/ci/testnet-deploy.sh

195 lines
4.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-08-27 20:37:35 -07:00
cd "$(dirname "$0")"/..
2018-12-22 12:34:30 -08:00
source ci/upload-ci-artifact.sh
2018-07-16 12:05:48 -07:00
zone=
bootstrapFullNodeAddress=
bootstrapFullNodeMachineType=
clientNodeCount=0
additionalFullNodeCount=10
publicNetwork=false
snapChannel=edge
2018-11-07 13:32:48 -08:00
tarChannelOrTag=edge
delete=false
2018-09-26 10:27:31 -07:00
enableGpu=false
2018-12-05 17:33:32 -08:00
leaderRotation=true
2018-11-07 13:32:48 -08:00
useTarReleaseChannel=false
2018-08-27 20:37:35 -07:00
usage() {
exitcode=0
if [[ -n "$1" ]]; then
exitcode=1
echo "Error: $*"
fi
cat <<EOF
2018-11-06 19:23:20 -08:00
usage: $0 [name] [cloud] [zone] [options...]
Deploys a CD testnet
name - name of the network
2018-11-06 19:23:20 -08:00
cloud - cloud provider to use (gce, ec2)
zone - cloud provider zone to deploy the network into
options:
-s edge|beta|stable - Deploy the specified Snap release channel
(default: $snapChannel)
2018-11-07 10:33:20 -08:00
-t edge|beta|stable|vX.Y.Z - Deploy the latest tarball release for the
specified release channel (edge|beta|stable) or release tag
(vX.Y.Z)
2018-11-07 13:32:48 -08:00
(default: $tarChannelOrTag)
-n [number] - Number of additional full nodes (default: $additionalFullNodeCount)
-c [number] - Number of client bencher nodes (default: $clientNodeCount)
-P - Use public network IP addresses (default: $publicNetwork)
-G - Enable GPU, and set count/type of GPUs to use (e.g n1-standard-16 --accelerator count=4,type=nvidia-tesla-k80)
2018-09-26 10:27:31 -07:00
-g - Enable GPU (default: $enableGpu)
2018-12-05 17:33:32 -08:00
-b - Disable leader rotation
-a [address] - Set the bootstrap fullnode's external IP address to this GCE address
-d - Delete the network
Note: the SOLANA_METRICS_CONFIG environment variable is used to configure
metrics
EOF
exit $exitcode
}
netName=$1
2018-11-06 19:23:20 -08:00
cloudProvider=$2
zone=$3
[[ -n $netName ]] || usage
2018-11-06 19:23:20 -08:00
[[ -n $cloudProvider ]] || usage "Cloud provider not specified"
[[ -n $zone ]] || usage "Zone not specified"
2018-11-06 19:23:20 -08:00
shift 3
2018-07-12 19:47:07 -07:00
2018-12-05 17:33:32 -08:00
while getopts "h?p:Pn:c:s:t:gG:a:db" opt; do
case $opt in
h | \?)
usage
2018-07-20 08:50:08 -07:00
;;
P)
publicNetwork=true
;;
2018-09-07 08:05:52 -07:00
n)
additionalFullNodeCount=$OPTARG
2018-09-07 08:05:52 -07:00
;;
c)
clientNodeCount=$OPTARG
;;
s)
case $OPTARG in
edge|beta|stable)
snapChannel=$OPTARG
;;
*)
usage "Invalid snap channel: $OPTARG"
;;
esac
;;
t)
case $OPTARG in
2018-11-07 10:33:20 -08:00
edge|beta|stable|v*)
2018-11-07 13:32:48 -08:00
tarChannelOrTag=$OPTARG
useTarReleaseChannel=true
;;
*)
usage "Invalid release channel: $OPTARG"
;;
esac
;;
2018-12-05 17:33:32 -08:00
b)
leaderRotation=false
;;
2018-09-26 10:27:31 -07:00
g)
enableGpu=true
;;
G)
enableGpu=true
bootstrapFullNodeMachineType=$OPTARG
;;
a)
bootstrapFullNodeAddress=$OPTARG
;;
d)
delete=true
2018-07-20 08:50:08 -07:00
;;
*)
usage "Error: unhandled option: $opt"
2018-07-20 08:50:08 -07:00
;;
esac
done
2018-11-06 19:23:20 -08:00
create_args=(
-a "$bootstrapFullNodeAddress"
-c "$clientNodeCount"
-n "$additionalFullNodeCount"
-p "$netName"
-z "$zone"
)
2018-09-26 10:27:31 -07:00
if $enableGpu; then
if [[ -z $bootstrapFullNodeMachineType ]]; then
2018-11-06 19:23:20 -08:00
create_args+=(-g)
else
create_args+=(-G "$bootstrapFullNodeMachineType")
fi
2018-09-26 10:27:31 -07:00
fi
2018-12-05 17:33:32 -08:00
if ! $leaderRotation; then
create_args+=(-b)
fi
if $publicNetwork; then
2018-11-06 19:23:20 -08:00
create_args+=(-P)
fi
2018-07-12 19:47:07 -07:00
shutdown() {
exitcode=$?
set +e
for logfile in net/log/*; do
if [[ -f $logfile ]]; then
upload-ci-artifact "$logfile"
tail "$logfile"
fi
done
exit $exitcode
}
trap shutdown EXIT INT
set -x
2018-11-06 19:23:20 -08:00
echo "--- $cloudProvider.sh delete"
time net/"$cloudProvider".sh delete -z "$zone" -p "$netName"
if $delete; then
exit 0
fi
2018-11-06 19:23:20 -08:00
echo "--- $cloudProvider.sh create"
time net/"$cloudProvider".sh create "${create_args[@]}"
net/init-metrics.sh -e
2018-09-06 20:38:11 -07:00
2018-09-06 21:07:11 -07:00
echo --- net.sh start
maybeRejectExtraNodes=
if ! $publicNetwork; then
maybeRejectExtraNodes="-o rejectExtraNodes"
fi
maybeNoValidatorSanity=
if [[ -n $NO_VALIDATOR_SANITY ]]; then
maybeNoValidatorSanity="-o noValidatorSanity"
fi
maybeNoLedgerVerify=
if [[ -n $NO_LEDGER_VERIFY ]]; then
maybeNoLedgerVerify="-o noLedgerVerify"
fi
# shellcheck disable=SC2086 # Don't want to double quote maybeRejectExtraNodes
2018-11-07 13:32:48 -08:00
if $useTarReleaseChannel; then
time net/net.sh start -t "$tarChannelOrTag" $maybeRejectExtraNodes $maybeNoValidatorSanity $maybeNoLedgerVerify
else
2018-11-07 13:32:48 -08:00
time net/net.sh start -s "$snapChannel" $maybeRejectExtraNodes $maybeNoValidatorSanity $maybeNoLedgerVerify
fi
2018-07-12 19:47:07 -07:00
exit 0