From 9ef9ed2785a84d47781fd6c71332dfc7240e5c3d Mon Sep 17 00:00:00 2001 From: kevinliu24 <20115614+kevinliu24@users.noreply.github.com> Date: Thu, 17 Jul 2025 18:18:52 -0700 Subject: [PATCH 1/2] Check mount point before mounting in raid disk script. --- .../raid-disks/eks-daemonset-raid-disks.yaml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/config/samples/raid-disks/eks-daemonset-raid-disks.yaml b/config/samples/raid-disks/eks-daemonset-raid-disks.yaml index c9b67049..1a6ef112 100644 --- a/config/samples/raid-disks/eks-daemonset-raid-disks.yaml +++ b/config/samples/raid-disks/eks-daemonset-raid-disks.yaml @@ -139,7 +139,21 @@ spec: mountpoint=/mnt/disks/raid0 mkdir -p "${mountpoint}" - echo "Mounting '${device}' at '${mountpoint}'" - mount -o discard,defaults "${device}" "${mountpoint}" - chmod a+w "${mountpoint}" + + echo "Checking if device '${device}' is already mounted at '${mountpoint}'" + device_real=$(readlink -f "$device") + if mountpoint -q "$mountpoint"; then + mounted_device=$(findmnt -nro SOURCE --target "$mountpoint" | xargs readlink -f) + + if [ "$mounted_device" != "$device_real" ]; then + echo "error: '${mountpoint}' is already mounted to '${mounted_device}', unable to mount '${device}'." + exit 1 + else + echo "'${device}' is already mounted to '${mountpoint}'. Skipping mount" + fi + else + echo "Mounting '${device}' at '${mountpoint}'" + mount -o discard,defaults "${device}" "${mountpoint}" + chmod a+w "${mountpoint}" + fi rm -rf /mnt/disks/raid0/* \ No newline at end of file From 0fbb9e3de3fcc61ec496a8ab3851cefa61e2a11e Mon Sep 17 00:00:00 2001 From: kevinliu24 <20115614+kevinliu24@users.noreply.github.com> Date: Thu, 17 Jul 2025 22:44:50 -0700 Subject: [PATCH 2/2] Add mountpoint check in gke raid disk script --- .../raid-disks/gke-daemonset-raid-disks.yaml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/config/samples/raid-disks/gke-daemonset-raid-disks.yaml b/config/samples/raid-disks/gke-daemonset-raid-disks.yaml index 0c430110..697f8b76 100644 --- a/config/samples/raid-disks/gke-daemonset-raid-disks.yaml +++ b/config/samples/raid-disks/gke-daemonset-raid-disks.yaml @@ -55,7 +55,21 @@ spec: mountpoint=/mnt/disks/raid0 mkdir -p "${mountpoint}" - echo "Mounting '${device}' at '${mountpoint}'" - mount -o discard,defaults "${device}" "${mountpoint}" - chmod a+w "${mountpoint}" + + echo "Checking if device '${device}' is already mounted at '${mountpoint}'" + device_real=$(readlink -f "$device") + if mountpoint -q "$mountpoint"; then + mounted_device=$(findmnt -nro SOURCE --target "$mountpoint" | xargs readlink -f) + + if [ "$mounted_device" != "$device_real" ]; then + echo "error: '${mountpoint}' is already mounted to '${mounted_device}', unable to mount '${device}'." + exit 1 + else + echo "'${device}' is already mounted to '${mountpoint}'. Skipping mount" + fi + else + echo "Mounting '${device}' at '${mountpoint}'" + mount -o discard,defaults "${device}" "${mountpoint}" + chmod a+w "${mountpoint}" + end rm -rf /mnt/disks/raid0/* \ No newline at end of file