Employ a startup script
This commit is contained in:
parent
6ffe205447
commit
9365a47d42
24
net/gce.sh
24
net/gce.sh
|
@ -123,21 +123,6 @@ prepareInstancesAndWriteConfigFile() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareInstance() {
|
|
||||||
declare name="$1"
|
|
||||||
declare publicIp="$3"
|
|
||||||
|
|
||||||
# TODO: Make the following a requirement of $imageName
|
|
||||||
# instead of a manual install
|
|
||||||
ssh "${sshOptions[@]}" "$publicIp" "
|
|
||||||
set -ex;
|
|
||||||
sudo systemctl disable apt-daily.service # disable run when system boot
|
|
||||||
sudo systemctl disable apt-daily.timer # disable timer run
|
|
||||||
sudo apt-get --assume-yes install rsync libssl-dev;
|
|
||||||
mkdir -p ~/solana ~/.cargo/bin;
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
gcloud_FindInstances "name=$prefix-leader" show
|
gcloud_FindInstances "name=$prefix-leader" show
|
||||||
[[ ${#instances[@]} -eq 1 ]] || {
|
[[ ${#instances[@]} -eq 1 ]] || {
|
||||||
echo "Unable to start leader"
|
echo "Unable to start leader"
|
||||||
|
@ -152,7 +137,6 @@ prepareInstancesAndWriteConfigFile() {
|
||||||
|
|
||||||
echo "leaderIp=()" >> "$configFile"
|
echo "leaderIp=()" >> "$configFile"
|
||||||
gcloud_ForEachInstance recordInstanceIp leaderIp
|
gcloud_ForEachInstance recordInstanceIp leaderIp
|
||||||
gcloud_ForEachInstance prepareInstance
|
|
||||||
|
|
||||||
gcloud_FindInstances "name~^$prefix-validator" show
|
gcloud_FindInstances "name~^$prefix-validator" show
|
||||||
[[ ${#instances[@]} -gt 0 ]] || {
|
[[ ${#instances[@]} -gt 0 ]] || {
|
||||||
|
@ -162,14 +146,12 @@ prepareInstancesAndWriteConfigFile() {
|
||||||
echo "validatorIpList=()" >> "$configFile"
|
echo "validatorIpList=()" >> "$configFile"
|
||||||
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
||||||
gcloud_ForEachInstance recordInstanceIp validatorIpList
|
gcloud_ForEachInstance recordInstanceIp validatorIpList
|
||||||
gcloud_ForEachInstance prepareInstance
|
|
||||||
|
|
||||||
echo "clientIpList=()" >> "$configFile"
|
echo "clientIpList=()" >> "$configFile"
|
||||||
gcloud_FindInstances "name~^$prefix-client" show
|
gcloud_FindInstances "name~^$prefix-client" show
|
||||||
if [[ ${#instances[@]} -gt 0 ]]; then
|
if [[ ${#instances[@]} -gt 0 ]]; then
|
||||||
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
gcloud_PrepInstancesForSsh "$gcloud_username" "$sshPrivateKey"
|
||||||
gcloud_ForEachInstance recordInstanceIp clientIpList
|
gcloud_ForEachInstance recordInstanceIp clientIpList
|
||||||
gcloud_ForEachInstance prepareInstance
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Wrote $configFile"
|
echo "Wrote $configFile"
|
||||||
|
@ -196,12 +178,12 @@ create)
|
||||||
echo ==================================================================
|
echo ==================================================================
|
||||||
echo
|
echo
|
||||||
gcloud_CreateInstances "$prefix-leader" 1 \
|
gcloud_CreateInstances "$prefix-leader" 1 \
|
||||||
"$zone" "$imageName" "$leaderMachineType" "$leaderAccelerator"
|
"$zone" "$imageName" "$leaderMachineType" "$leaderAccelerator" "$here/remote/remote_startup.sh"
|
||||||
gcloud_CreateInstances "$prefix-validator" "$validatorNodeCount" \
|
gcloud_CreateInstances "$prefix-validator" "$validatorNodeCount" \
|
||||||
"$zone" "$imageName" "$validatorMachineType" "$validatorAccelerator"
|
"$zone" "$imageName" "$validatorMachineType" "$validatorAccelerator" "$here/remote/remote_startup.sh"
|
||||||
if [[ -n $clientNodeCount ]]; then
|
if [[ -n $clientNodeCount ]]; then
|
||||||
gcloud_CreateInstances "$prefix-client" "$clientNodeCount" \
|
gcloud_CreateInstances "$prefix-client" "$clientNodeCount" \
|
||||||
"$zone" "$imageName" "$clientMachineType" "$clientAccelerator"
|
"$zone" "$imageName" "$clientMachineType" "$clientAccelerator" "$here/remote/remote_startup.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prepareInstancesAndWriteConfigFile
|
prepareInstancesAndWriteConfigFile
|
||||||
|
|
|
@ -120,6 +120,7 @@ common_start_setup() {
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
test -d "$SOLANA_ROOT"
|
test -d "$SOLANA_ROOT"
|
||||||
|
ssh "${sshOptions[@]}" "$ipAddress" "mkdir -p ~/solana ~/.cargo/bin"
|
||||||
rsync -vPrz -e "ssh ${sshOptions[*]}" \
|
rsync -vPrz -e "ssh ${sshOptions[*]}" \
|
||||||
"$SOLANA_ROOT"/{fetch-perf-libs.sh,scripts,net,multinode-demo} \
|
"$SOLANA_ROOT"/{fetch-perf-libs.sh,scripts,net,multinode-demo} \
|
||||||
"$ipAddress":~/solana/
|
"$ipAddress":~/solana/
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Runs at boot on each instance as root
|
||||||
|
#
|
||||||
|
# TODO: Make the following a requirement of the Instance image
|
||||||
|
# instead of a manual install?
|
||||||
|
|
||||||
|
systemctl disable apt-daily.service # disable run when system boot
|
||||||
|
systemctl disable apt-daily.timer # disable timer run
|
||||||
|
apt-get --assume-yes install rsync libssl-dev
|
||||||
|
|
|
@ -75,7 +75,7 @@ gcloud_ForEachInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# gcloud_CreateInstances [namePrefix] [numNodes] [zone] [imageName] [machineType] [accelerator]
|
# gcloud_CreateInstances [namePrefix] [numNodes] [zone] [imageName] [machineType] [accelerator] [startupScript]
|
||||||
#
|
#
|
||||||
# Creates one more identical instances.
|
# Creates one more identical instances.
|
||||||
#
|
#
|
||||||
|
@ -86,6 +86,7 @@ gcloud_ForEachInstance() {
|
||||||
# machineType - GCE machine type
|
# machineType - GCE machine type
|
||||||
# accelerator - Optional accelerator to attach to the instance(s), see
|
# accelerator - Optional accelerator to attach to the instance(s), see
|
||||||
# eg, request 4 K80 GPUs with "count=4,type=nvidia-tesla-k80"
|
# eg, request 4 K80 GPUs with "count=4,type=nvidia-tesla-k80"
|
||||||
|
# startupScript - Optional startup script to execute when the instance boots
|
||||||
#
|
#
|
||||||
# Tip: use gcloud_FindInstances to locate the instances once this function
|
# Tip: use gcloud_FindInstances to locate the instances once this function
|
||||||
# returns
|
# returns
|
||||||
|
@ -96,6 +97,7 @@ gcloud_CreateInstances() {
|
||||||
declare imageName="$4"
|
declare imageName="$4"
|
||||||
declare machineType="$5"
|
declare machineType="$5"
|
||||||
declare optionalAccelerator="$6"
|
declare optionalAccelerator="$6"
|
||||||
|
declare optionalStartupScript="$7"
|
||||||
|
|
||||||
declare nodes
|
declare nodes
|
||||||
if [[ $numNodes = 1 ]]; then
|
if [[ $numNodes = 1 ]]; then
|
||||||
|
@ -119,6 +121,12 @@ gcloud_CreateInstances() {
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n $optionalStartupScript ]]; then
|
||||||
|
args+=(
|
||||||
|
--metadata-from-file "startup-script=$optionalStartupScript"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
gcloud beta compute instances create "${nodes[@]}" "${args[@]}"
|
gcloud beta compute instances create "${nodes[@]}" "${args[@]}"
|
||||||
|
|
Loading…
Reference in New Issue