Add support for additional disks for config-local (#5030)
* Add support for additional disks for config-local * Restore wrongly deleted lines * Shellcheck * add args in the right place dummy * Fix nits * typo * var naming cleanup * Add stub function for remaining cloud providers
This commit is contained in:
@ -309,3 +309,12 @@ cloud_FetchFile() {
|
||||
cloud_GetConfigValueFromInstanceName "$instanceName" osProfile.adminUsername
|
||||
scp "${config_value}@${publicIp}:${remoteFile}" "$localFile"
|
||||
}
|
||||
|
||||
#
|
||||
# cloud_CreateAndAttachPersistentDisk
|
||||
#
|
||||
# Not yet implemented for this cloud provider
|
||||
cloud_CreateAndAttachPersistentDisk() {
|
||||
echo "ERROR: cloud_CreateAndAttachPersistentDisk is not yet implemented for azure"
|
||||
exit 1
|
||||
}
|
@ -381,3 +381,12 @@ cloud_FetchFile() {
|
||||
"solana@$publicIp:$remoteFile" "$localFile"
|
||||
)
|
||||
}
|
||||
|
||||
#
|
||||
# cloud_CreateAndAttachPersistentDisk
|
||||
#
|
||||
# Not yet implemented for this cloud provider
|
||||
cloud_CreateAndAttachPersistentDisk() {
|
||||
echo "ERROR: cloud_CreateAndAttachPersistentDisk is not yet implemented for ec2"
|
||||
exit 1
|
||||
}
|
@ -126,6 +126,7 @@ cloud_CreateInstances() {
|
||||
declare optionalStartupScript="$8"
|
||||
declare optionalAddress="$9"
|
||||
declare optionalBootDiskType="${10}"
|
||||
declare optionalAdditionalDiskSize="${11}"
|
||||
|
||||
if $enableGpu; then
|
||||
# Custom Ubuntu 18.04 LTS image with CUDA 9.2 and CUDA 10.0 installed
|
||||
@ -198,6 +199,22 @@ cloud_CreateInstances() {
|
||||
set -x
|
||||
gcloud beta compute instances create "${nodes[@]}" "${args[@]}"
|
||||
)
|
||||
|
||||
if [[ -n $optionalAdditionalDiskSize ]]; then
|
||||
if [[ $numNodes = 1 ]]; then
|
||||
(
|
||||
set -x
|
||||
cloud_CreateAndAttachPersistentDisk "${namePrefix}" "$optionalAdditionalDiskSize" "pd-ssd" "$zone"
|
||||
)
|
||||
else
|
||||
for node in $(seq -f "${namePrefix}%0${#numNodes}g" 1 "$numNodes"); do
|
||||
(
|
||||
set -x
|
||||
cloud_CreateAndAttachPersistentDisk "${node}" "$optionalAdditionalDiskSize" "pd-ssd" "$zone"
|
||||
)
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
@ -256,3 +273,31 @@ cloud_FetchFile() {
|
||||
gcloud compute scp --zone "$zone" "$instanceName:$remoteFile" "$localFile"
|
||||
)
|
||||
}
|
||||
|
||||
#
|
||||
# cloud_CreateAndAttachPersistentDisk [instanceName] [diskSize] [diskType]
|
||||
#
|
||||
# Create a persistent disk and attach it to a pre-existing VM instance.
|
||||
# Set disk to auto-delete upon instance deletion
|
||||
#
|
||||
cloud_CreateAndAttachPersistentDisk() {
|
||||
declare instanceName="$1"
|
||||
declare diskSize="$2"
|
||||
declare diskType="$3"
|
||||
declare zone="$4"
|
||||
diskName="${instanceName}-pd"
|
||||
|
||||
gcloud beta compute disks create "$diskName" \
|
||||
--size "$diskSize" \
|
||||
--type "$diskType" \
|
||||
--zone "$zone"
|
||||
|
||||
gcloud compute instances attach-disk "$instanceName" \
|
||||
--disk "$diskName" \
|
||||
--zone "$zone"
|
||||
|
||||
gcloud compute instances set-disk-auto-delete "$instanceName" \
|
||||
--disk "$diskName" \
|
||||
--zone "$zone" \
|
||||
--auto-delete
|
||||
}
|
||||
|
21
net/scripts/mount-additional-disk.sh
Executable file
21
net/scripts/mount-additional-disk.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
mount_point=/mnt/extra-disk
|
||||
disk=sdb
|
||||
if ! lsblk | grep -q ${disk} ; then
|
||||
echo "${disk} does not exist"
|
||||
else
|
||||
if mount | grep -q ${disk} ; then
|
||||
echo "${disk} is already mounted"
|
||||
else
|
||||
sudo mkfs.ext4 -F /dev/"$disk"
|
||||
sudo mkdir -p "$mount_point"
|
||||
sudo mount /dev/"$disk" "$mount_point"
|
||||
sudo chmod a+w "$mount_point"
|
||||
if ! mount | grep -q ${mount_point} ; then
|
||||
echo "${disk} failed to mount!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user