Add support for preemptible GCP instances
This commit is contained in:
@ -8,6 +8,10 @@ cloud_DefaultZone() {
|
||||
echo "westus"
|
||||
}
|
||||
|
||||
cloud_RestartPreemptedInstances() {
|
||||
: # Not implemented
|
||||
}
|
||||
|
||||
#
|
||||
# __cloud_GetConfigValueFromInstanceName
|
||||
# Return a piece of configuration information about an instance
|
||||
|
@ -16,6 +16,10 @@ cloud_DefaultZone() {
|
||||
echo "Denver"
|
||||
}
|
||||
|
||||
cloud_RestartPreemptedInstances() {
|
||||
: # Not implemented
|
||||
}
|
||||
|
||||
#
|
||||
# __cloud_FindInstances
|
||||
#
|
||||
@ -134,6 +138,7 @@ cloud_Initialize() {
|
||||
# has been provisioned in the GCE region that is hosting `$zone`
|
||||
# bootDiskType - Optional specify SSD or HDD boot disk
|
||||
# additionalDiskSize - Optional specify size of additional storage volume
|
||||
# preemptible - Optionally request a preemptible instance ("true")
|
||||
#
|
||||
# Tip: use cloud_FindInstances to locate the instances once this function
|
||||
# returns
|
||||
@ -149,7 +154,8 @@ cloud_CreateInstances() {
|
||||
#declare optionalAddress="$9" # unused
|
||||
#declare optionalBootDiskType="${10}" # unused
|
||||
#declare optionalAdditionalDiskSize="${11}" # unused
|
||||
declare sshPrivateKey="${12}"
|
||||
#declare optionalPreemptible="${12}" # unused
|
||||
declare sshPrivateKey="${13}"
|
||||
|
||||
declare -a nodes
|
||||
if [[ $numNodes = 1 ]]; then
|
||||
|
@ -7,6 +7,10 @@ cloud_DefaultZone() {
|
||||
echo "us-east-1b"
|
||||
}
|
||||
|
||||
cloud_RestartPreemptedInstances() {
|
||||
: # Not implemented
|
||||
}
|
||||
|
||||
# AWS region is zone with the last character removed
|
||||
__cloud_GetRegion() {
|
||||
declare zone="$1"
|
||||
|
@ -8,6 +8,29 @@ cloud_DefaultZone() {
|
||||
echo "us-west1-b"
|
||||
}
|
||||
|
||||
#
|
||||
# cloud_RestartPreemptedInstances [namePrefix]
|
||||
#
|
||||
# Restart any preempted instances matching the specified prefix
|
||||
#
|
||||
# namePrefix - The instance name prefix of the preempted instances
|
||||
#
|
||||
cloud_RestartPreemptedInstances() {
|
||||
declare filter="$1"
|
||||
|
||||
declare name status zone
|
||||
while read -r name status zone; do
|
||||
echo "Starting $status instance: $name"
|
||||
(
|
||||
set -x
|
||||
gcloud compute instances start --zone "$zone" "$name"
|
||||
)
|
||||
done < <(gcloud compute instances list \
|
||||
--filter "$filter" \
|
||||
--format 'value(name,status,zone)' \
|
||||
| grep TERMINATED)
|
||||
}
|
||||
|
||||
#
|
||||
# __cloud_FindInstances
|
||||
#
|
||||
@ -125,6 +148,7 @@ cloud_Initialize() {
|
||||
# has been provisioned in the GCE region that is hosting `$zone`
|
||||
# bootDiskType - Optional specify SSD or HDD boot disk
|
||||
# additionalDiskSize - Optional specify size of additional storage volume
|
||||
# preemptible - Optionally request a preemptible instance ("true")
|
||||
#
|
||||
# Tip: use cloud_FindInstances to locate the instances once this function
|
||||
# returns
|
||||
@ -140,6 +164,8 @@ cloud_CreateInstances() {
|
||||
declare optionalAddress="$9"
|
||||
declare optionalBootDiskType="${10}"
|
||||
declare optionalAdditionalDiskSize="${11}"
|
||||
declare optionalPreemptible="${12}"
|
||||
#declare sshPrivateKey="${13}" # unused
|
||||
|
||||
if $enableGpu; then
|
||||
# Custom Ubuntu 18.04 LTS image with CUDA 9.2 and CUDA 10.0 installed
|
||||
@ -176,6 +202,10 @@ cloud_CreateInstances() {
|
||||
# shellcheck disable=SC2206 # Do not want to quote $imageName as it may contain extra args
|
||||
args+=(--image $imageName)
|
||||
|
||||
if [[ $optionalPreemptible = true ]]; then
|
||||
args+=(--preemptible)
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2206 # Do not want to quote $machineType as it may contain extra args
|
||||
for word in $machineType; do
|
||||
# Special handling for the "--min-cpu-platform" argument which may contain a
|
||||
|
Reference in New Issue
Block a user