From 8ae59105c5c300e92c63eee733dd0571c2387cb7 Mon Sep 17 00:00:00 2001 From: Tom Ashley Date: Thu, 14 Aug 2025 08:22:20 +0100 Subject: [PATCH 1/3] fix: ensure amazon-ec2-utils is installed before 24.04 upgrade --- .../files/admin_api_scripts/pg_upgrade_scripts/initiate.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh index 9017f6169..f84c08ce5 100755 --- a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh +++ b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh @@ -350,6 +350,13 @@ function initiate_upgrade { if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then # DATABASE_UPGRADE_DATA_MIGRATION_DEVICE_NAME = '/dev/xvdp' can be derived from the worker mount echo "5. Determining block device to mount" + # lsb release + UBUNTU_VERSION=$(lsb_release -rs) + # install amazon disk utilities if not present on 24.04 + if [ "${UBUNTU_VERSION}" = "24.04" ] && ! dpkg -l | grep -q amazon-ec2-utils; then + apt-get update + apt-get install -y amazon-ec2-utils || true + fi if command -v ebsnvme-id >/dev/null 2>&1 && dpkg -l | grep -q amazon-ec2-utils; then for nvme_dev in $(lsblk -dprno name,size,mountpoint,type | grep disk | awk '{print $1}'); do if [ -b "$nvme_dev" ]; then From 48b3ea27e9a92b8bd1c5fb346600c39e84eceaaf Mon Sep 17 00:00:00 2001 From: Tom Ashley Date: Thu, 14 Aug 2025 09:14:15 +0100 Subject: [PATCH 2/3] fix: detect package installed, pipefail friendly --- .../files/admin_api_scripts/pg_upgrade_scripts/initiate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh index f84c08ce5..71016a294 100755 --- a/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh +++ b/ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh @@ -353,11 +353,11 @@ function initiate_upgrade { # lsb release UBUNTU_VERSION=$(lsb_release -rs) # install amazon disk utilities if not present on 24.04 - if [ "${UBUNTU_VERSION}" = "24.04" ] && ! dpkg -l | grep -q amazon-ec2-utils; then + if [ "${UBUNTU_VERSION}" = "24.04" ] && ! /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then apt-get update apt-get install -y amazon-ec2-utils || true fi - if command -v ebsnvme-id >/dev/null 2>&1 && dpkg -l | grep -q amazon-ec2-utils; then + if command -v ebsnvme-id >/dev/null 2>&1 && /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then for nvme_dev in $(lsblk -dprno name,size,mountpoint,type | grep disk | awk '{print $1}'); do if [ -b "$nvme_dev" ]; then mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null) From eba3c65fb685724f668804a07394c7cdc974da52 Mon Sep 17 00:00:00 2001 From: Tom Ashley Date: Thu, 14 Aug 2025 09:17:58 +0100 Subject: [PATCH 3/3] fix: pipefail friendly way to detect package --- ansible/files/admin_api_scripts/grow_fs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/files/admin_api_scripts/grow_fs.sh b/ansible/files/admin_api_scripts/grow_fs.sh index 6d9fc8a16..01e4736ed 100644 --- a/ansible/files/admin_api_scripts/grow_fs.sh +++ b/ansible/files/admin_api_scripts/grow_fs.sh @@ -13,7 +13,7 @@ if pgrep resizefs; then fi # install amazon disk utilities if not present on 24.04 -if [ "${UBUNTU_VERSION}" = "24.04" ] && ! dpkg -l | grep -q amazon-ec2-utils; then +if [ "${UBUNTU_VERSION}" = "24.04" ] && ! /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then apt-get update apt-get install -y amazon-ec2-utils || true fi @@ -26,7 +26,7 @@ fi XVDA_DEVICE="/dev/nvme0n1" XVDH_DEVICE="/dev/nvme1n1" # Map AWS devices to NVMe for ubuntu 24.04 and later -if [ "${UBUNTU_VERSION}" = "24.04" ] && dpkg -l | grep -q amazon-ec2-utils; then +if [ "${UBUNTU_VERSION}" = "24.04" ] && /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then for nvme_dev in $(lsblk -dprno name,type | grep disk | awk '{print $1}'); do if [ -b "$nvme_dev" ]; then mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null)