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 \ diff --git a/scripts/validate.sh b/scripts/validate.sh index 0b007e386..0b1e37c92 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,14 @@ for ENTRY in "${REQUIRED_COMMANDS[@]}"; do done echo "Required commands were found: ${REQUIRED_COMMANDS[*]}" + +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