From e639d0cf5dd52434d3e43e548de016691d5214f4 Mon Sep 17 00:00:00 2001 From: Carter McKinnon Date: Mon, 15 May 2023 12:26:06 -0700 Subject: [PATCH 1/3] Install kernel-headers, kernel-devel --- scripts/install-worker.sh | 2 +- scripts/upgrade_kernel.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install-worker.sh b/scripts/install-worker.sh index d8bdafdcd..ac0e799d6 100644 --- a/scripts/install-worker.sh +++ b/scripts/install-worker.sh @@ -77,7 +77,7 @@ sudo yum install -y \ # Remove any old kernel versions. `--count=1` here means "only leave 1 kernel version installed" sudo package-cleanup --oldkernels --count=1 -y -sudo yum versionlock kernel-$(uname -r) +sudo yum versionlock kernel-$(uname -r) kernel-headers-$(uname -r) kernel-devel-$(uname -r) # Remove the ec2-net-utils package, if it's installed. This package interferes with the route setup on the instance. if yum list installed | grep ec2-net-utils; then sudo yum remove ec2-net-utils -y -q; fi diff --git a/scripts/upgrade_kernel.sh b/scripts/upgrade_kernel.sh index 67e509caa..4da5a3576 100755 --- a/scripts/upgrade_kernel.sh +++ b/scripts/upgrade_kernel.sh @@ -19,6 +19,8 @@ else sudo amazon-linux-extras install -y "kernel-${KERNEL_VERSION}" fi +sudo yum install -y kernel-headers kernel-devel + # enable pressure stall information sudo grubby \ --update-kernel=ALL \ From befe70e5656c7027c8db3621a12e82cc94152ea8 Mon Sep 17 00:00:00 2001 From: Carter McKinnon Date: Fri, 2 Jun 2023 14:09:18 -0700 Subject: [PATCH 2/3] Add validatin for free disk space (1 GiB) --- scripts/validate.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/validate.sh b/scripts/validate.sh index 0b007e386..15cecd6af 100644 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash -# -# Do basic validation of the generated AMI - -# Validates that a file or blob doesn't exist -# -# Arguments: -# a file name or blob -# Returns: -# 1 if a file exists, after printing an error + +set -o nounset +set -o errexit +set -o pipefail + validate_file_nonexists() { local file_blob=$1 for f in $file_blob; do @@ -84,3 +80,18 @@ for ENTRY in "${REQUIRED_COMMANDS[@]}"; do done echo "Required commands were found: ${REQUIRED_COMMANDS[*]}" + +function free-space-in-megabytes () { + df -m / | tail -n1 | awk '{print $4}' +} + +REQUIRED_FREE_MEBIBYTES=1024 +TOTAL_MEBIBYTES=$(df -m / | tail -n1 | awk '{print $2}') +FREE_MEBIBYTES=$(df -m / | tail -n1 | awk '{print $4}') +echo "Disk space in mebibytes (required/free/total): ${REQUIRED_FREE_MEBIBYTES}/${FREE_MEBIBYTES}/${TOTAL_MEBIBYTES}" +if [ ${FREE_MEBIBYTES} -lt ${REQUIRED_FREE_MEBIBYTES} ]; then + echo "Disk space requirements not met!" + exit 1 +else + echo "Disk space requirements were met." +fi From 9f51866c6198f752717cc269a2a789ee6aa19adb Mon Sep 17 00:00:00 2001 From: Carter McKinnon Date: Mon, 5 Jun 2023 12:44:34 -0700 Subject: [PATCH 3/3] Fix lint findings --- scripts/validate.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/validate.sh b/scripts/validate.sh index 15cecd6af..0b1e37c92 100644 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -81,10 +81,6 @@ done echo "Required commands were found: ${REQUIRED_COMMANDS[*]}" -function free-space-in-megabytes () { - df -m / | tail -n1 | awk '{print $4}' -} - REQUIRED_FREE_MEBIBYTES=1024 TOTAL_MEBIBYTES=$(df -m / | tail -n1 | awk '{print $2}') FREE_MEBIBYTES=$(df -m / | tail -n1 | awk '{print $4}')