Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instance storage mount script fails when instance storage not available #1206

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packer/linux/conf/bin/bk-mount-instance-storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ exec > >(tee -a /var/log/elastic-stack.log | logger -t user-data -s 2>/dev/conso
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html

if [[ "${BUILDKITE_ENABLE_INSTANCE_STORAGE:-false}" != "true" ]]; then
echo "Skipping mounting instance storage"
echo Skipping mounting instance storage >&2
exit 0
fi

#shellcheck disable=SC2207
devices=($(nvme list | grep "Amazon EC2 NVMe Instance Storage" | cut -f1 -d' '))
devices=($(nvme list | grep "Amazon EC2 NVMe Instance Storage" | cut -f1 -d' ' || true))

if [ -z "${devices[*]}" ]; then
echo "No Instance Storage NVMe drives to mount" >&2
if [[ -z "${devices[*]}" ]]; then
echo No NVMe drives to mount. >&2
echo Please check that your instance type supports instance storage >&2
exit 0
fi

Expand Down
5 changes: 4 additions & 1 deletion templates/aws-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ Parameters:

EnableInstanceStorage:
Type: String
Description: Mount available NVMe Instance Storage at /mnt/ephemeral
Description: >
Mount available NVMe Instance Storage at /mnt/ephemeral, and use it to store docker images and
containers, and the build working directory. You must ensure that the instance types have
instance storage available for this to have any effect. See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-store-volumes.html
AllowedValues:
- "true"
- "false"
Expand Down