Skip to content

Commit 2262dde

Browse files
authored
fix: accurately determine disk mount for upgrade disk xvdp (#1740)
* chore: install amazon-ec2-utils for ebs nvme mapping tool * fix: accurately determine disk mount for upgrade disk xvdp
1 parent cf87390 commit 2262dde

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,28 @@ function initiate_upgrade {
348348
locale-gen
349349

350350
if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
351-
# awk NF==3 prints lines with exactly 3 fields, which are the block devices currently not mounted anywhere
352-
# excluding nvme0 since it is the root disk
351+
# DATABASE_UPGRADE_DATA_MIGRATION_DEVICE_NAME = '/dev/xvdp' can be derived from the worker mount
353352
echo "5. Determining block device to mount"
354-
BLOCK_DEVICE=$(lsblk -dprno name,size,mountpoint,type | grep "disk" | grep -v "nvme0" | awk 'NF==3 { print $1; }')
353+
if command -v ebsnvme-id >/dev/null 2>&1 && dpkg -l | grep -q amazon-ec2-utils; then
354+
for nvme_dev in $(lsblk -dprno name,size,mountpoint,type | grep disk | awk '{print $1}'); do
355+
if [ -b "$nvme_dev" ]; then
356+
mapping=$(ebsnvme-id -b "$nvme_dev" 2>/dev/null)
357+
if [[ "$mapping" == "xvdp" || $mapping == "/dev/xvdp" ]]; then
358+
BLOCK_DEVICE="$nvme_dev"
359+
break
360+
fi
361+
fi
362+
done
363+
fi
364+
365+
# Fallback to lsblk if ebsnvme-id is not available or no mapping found, pre ubuntu 20.04
366+
if [ -z "$BLOCK_DEVICE" ]; then
367+
echo "No block device found using ebsnvme-id, falling back to lsblk"
368+
# awk NF==3 prints lines with exactly 3 fields, which are the block devices currently not mounted anywhere
369+
# excluding nvme0 since it is the root disk
370+
BLOCK_DEVICE=$(lsblk -dprno name,size,mountpoint,type | grep "disk" | grep -v "nvme0" | awk 'NF==3 { print $1; exit }') # exit ensures we grab the first only
371+
fi
372+
355373
echo "Block device found: $BLOCK_DEVICE"
356374

357375
mkdir -p "$MOUNT_POINT"

ansible/tasks/setup-supabase-internal.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
shell: "/tmp/aws/install --update"
3030
become: true
3131

32+
- name: install utilities to manage Amazon EC2 instance storage
33+
become: true
34+
apt:
35+
pkg:
36+
- amazon-ec2-utils
37+
3238
- name: AWS CLI - configure ipv6 support for s3
3339
shell: |
3440
aws configure set default.s3.use_dualstack_endpoint true

0 commit comments

Comments
 (0)