From 797f81249548d8ff6a65c15d3272a5e9dd270bcc Mon Sep 17 00:00:00 2001 From: Narthana Epa Date: Fri, 1 Sep 2023 15:51:36 +1000 Subject: [PATCH 1/3] Better error messages for mounting instance storage --- packer/linux/conf/bin/bk-mount-instance-storage.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packer/linux/conf/bin/bk-mount-instance-storage.sh b/packer/linux/conf/bin/bk-mount-instance-storage.sh index 3d90f3b22..6f48b9ab8 100755 --- a/packer/linux/conf/bin/bk-mount-instance-storage.sh +++ b/packer/linux/conf/bin/bk-mount-instance-storage.sh @@ -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' ')) -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 From 614cc4980e137b73969e28f29d16afe4d55989e8 Mon Sep 17 00:00:00 2001 From: Narthana Epa Date: Fri, 1 Sep 2023 15:51:53 +1000 Subject: [PATCH 2/3] Don't fail when instance storage not available --- packer/linux/conf/bin/bk-mount-instance-storage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/linux/conf/bin/bk-mount-instance-storage.sh b/packer/linux/conf/bin/bk-mount-instance-storage.sh index 6f48b9ab8..350c61249 100755 --- a/packer/linux/conf/bin/bk-mount-instance-storage.sh +++ b/packer/linux/conf/bin/bk-mount-instance-storage.sh @@ -14,7 +14,7 @@ if [[ "${BUILDKITE_ENABLE_INSTANCE_STORAGE:-false}" != "true" ]]; then 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 NVMe drives to mount. >&2 From dd349aca8364a4c5351c23061aa8f4fb644d746f Mon Sep 17 00:00:00 2001 From: Narthana Epa Date: Mon, 4 Sep 2023 16:57:27 +1000 Subject: [PATCH 3/3] Update description of EnableInstanceStorage parameter We should tell the user to make sure that the instance type they are using has instance storage. --- templates/aws-stack.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/aws-stack.yml b/templates/aws-stack.yml index 7dd3ca90d..190eeb442 100644 --- a/templates/aws-stack.yml +++ b/templates/aws-stack.yml @@ -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"