Skip to content

Commit defc662

Browse files
authored
fix: ensure amazon-ec2-utils is installed before 24.04 upgrade (#1759)
* fix: ensure amazon-ec2-utils is installed before 24.04 upgrade * fix: detect package installed, pipefail friendly * fix: pipefail friendly way to detect package
1 parent 24430ee commit defc662

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ansible/files/admin_api_scripts/grow_fs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if pgrep resizefs; then
1313
fi
1414

1515
# install amazon disk utilities if not present on 24.04
16-
if [ "${UBUNTU_VERSION}" = "24.04" ] && ! dpkg -l | grep -q amazon-ec2-utils; then
16+
if [ "${UBUNTU_VERSION}" = "24.04" ] && ! /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then
1717
apt-get update
1818
apt-get install -y amazon-ec2-utils || true
1919
fi
@@ -26,7 +26,7 @@ fi
2626
XVDA_DEVICE="/dev/nvme0n1"
2727
XVDH_DEVICE="/dev/nvme1n1"
2828
# Map AWS devices to NVMe for ubuntu 24.04 and later
29-
if [ "${UBUNTU_VERSION}" = "24.04" ] && dpkg -l | grep -q amazon-ec2-utils; then
29+
if [ "${UBUNTU_VERSION}" = "24.04" ] && /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then
3030
for nvme_dev in $(lsblk -dprno name,type | grep disk | awk '{print $1}'); do
3131
if [ -b "$nvme_dev" ]; then
3232
mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null)

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,14 @@ function initiate_upgrade {
350350
if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
351351
# DATABASE_UPGRADE_DATA_MIGRATION_DEVICE_NAME = '/dev/xvdp' can be derived from the worker mount
352352
echo "5. Determining block device to mount"
353-
if command -v ebsnvme-id >/dev/null 2>&1 && dpkg -l | grep -q amazon-ec2-utils; then
353+
# lsb release
354+
UBUNTU_VERSION=$(lsb_release -rs)
355+
# install amazon disk utilities if not present on 24.04
356+
if [ "${UBUNTU_VERSION}" = "24.04" ] && ! /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then
357+
apt-get update
358+
apt-get install -y amazon-ec2-utils || true
359+
fi
360+
if command -v ebsnvme-id >/dev/null 2>&1 && /usr/bin/dpkg-query -W amazon-ec2-utils >/dev/null 2>&1; then
354361
for nvme_dev in $(lsblk -dprno name,size,mountpoint,type | grep disk | awk '{print $1}'); do
355362
if [ -b "$nvme_dev" ]; then
356363
mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null)

0 commit comments

Comments
 (0)