From bfaae43b22a3b687096352c39ade0546fd293883 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Thu, 26 Jan 2023 13:08:42 +0000 Subject: [PATCH 1/5] :bug: Switch blobfuse caches to be 2% of the OS disk size --- .../cloud_init/cloud-init-srd.mustache.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml b/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml index 67daace3d2..91ccd18d14 100644 --- a/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml +++ b/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml @@ -415,7 +415,7 @@ write_files: BLOBFUSE_CACHE_DIR="/tmp/blobfuse-cache-backup" rm -rf $BLOBFUSE_CACHE_DIR mkdir -p $BLOBFUSE_CACHE_DIR - CACHE_SPACE_MB=$(echo "$(df -BM | grep /mnt | awk '{print $2}' | sed 's/M//') / 2" | bc) # set the cache size to half the size of /mnt which scales with VM size + CACHE_SPACE_MB=$(echo "$(df -BM | grep /dev/root | awk '{print $2}' | sed 's/M//') / 50" | bc) # set the cache size to 2% of the OS disk size /usr/bin/blobfuse $1 -o rw --tmp-path=$BLOBFUSE_CACHE_DIR --cache-size-mb=$CACHE_SPACE_MB --no-symlinks=true --config-file=/opt/configuration/credentials-backup.secret --log-level=LOG_DEBUG -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other fi @@ -426,7 +426,7 @@ write_files: BLOBFUSE_CACHE_DIR="/tmp/blobfuse-cache-egress" rm -rf $BLOBFUSE_CACHE_DIR mkdir -p $BLOBFUSE_CACHE_DIR - CACHE_SPACE_MB=$(echo "$(df -BM | grep /mnt | awk '{print $2}' | sed 's/M//') / 2" | bc) # set the cache size to half the size of /mnt which scales with VM size + CACHE_SPACE_MB=$(echo "$(df -BM | grep /dev/root | awk '{print $2}' | sed 's/M//') / 50" | bc) # set the cache size to 2% of the OS disk size /usr/bin/blobfuse $1 -o rw --tmp-path=$BLOBFUSE_CACHE_DIR --cache-size-mb=$CACHE_SPACE_MB --no-symlinks=true --config-file=/opt/configuration/credentials-egress.secret --log-level=LOG_DEBUG -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other fi @@ -437,7 +437,7 @@ write_files: BLOBFUSE_CACHE_DIR="/tmp/blobfuse-cache-ingress" rm -rf $BLOBFUSE_CACHE_DIR mkdir -p $BLOBFUSE_CACHE_DIR - CACHE_SPACE_MB=$(echo "$(df -BM | grep /mnt | awk '{print $2}' | sed 's/M//') / 2" | bc) # set the cache size to half the size of /mnt which scales with VM size + CACHE_SPACE_MB=$(echo "$(df -BM | grep /dev/root | awk '{print $2}' | sed 's/M//') / 50" | bc) # set the cache size to 2% of the OS disk size /usr/bin/blobfuse $1 -o ro --tmp-path=$BLOBFUSE_CACHE_DIR --cache-size-mb=$CACHE_SPACE_MB --no-symlinks=true --config-file=/opt/configuration/credentials-ingress.secret --log-level=LOG_DEBUG -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other fi From e85f6519e0b79938595d3f6468d93d9768326dc1 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Thu, 26 Jan 2023 13:09:03 +0000 Subject: [PATCH 2/5] :bug: Fix shellcheck warnings in drive checking script --- .../scripts/check_drive_mounts.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh b/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh index 426edd56ed..ece5f457ae 100644 --- a/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh +++ b/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh @@ -10,15 +10,16 @@ END="\033[0m" MOUNT_POINTS=("/data" "/home" "/scratch" "/shared" "/output") echo -e "${BLUE}Checking drives are mounted...${END}" for MOUNT_POINT in "${MOUNT_POINTS[@]}"; do - ls ${MOUNT_POINT}/* > /dev/null 2>&1 - if [ "$(mount | grep $MOUNT_POINT)" ]; then + ls "${MOUNT_POINT}"/* > /dev/null 2>&1 + if (mount | grep -q "$MOUNT_POINT"); then echo -e "${BLUE} [o] ${MOUNT_POINT} is mounted...${END}" else echo -e "${RED} [ ] ${MOUNT_POINT} not mounted. Attempting to mount...${END}" - if [ -e /etc/systemd/system/${MOUNT_POINT}.mount ]; then - systemctl start $(echo $MOUNT_POINT | sed 's|/||').mount + MOUNT_UNIT="$(echo "$MOUNT_POINT" | tr -d '/').mount" + if [ -e "/etc/systemd/system/${MOUNT_UNIT}" ]; then + systemctl start "${MOUNT_UNIT}" else - mount $MOUNT_POINT + mount "$MOUNT_POINT" fi fi done @@ -26,10 +27,10 @@ sleep 30 echo -e "${BLUE}Rechecking drives are mounted...${END}" for MOUNT_POINT in "${MOUNT_POINTS[@]}"; do - ls ${MOUNT_POINT}/* > /dev/null 2>&1 - if [ "$(mount | grep $MOUNT_POINT)" ]; then + ls "${MOUNT_POINT}"/* > /dev/null 2>&1 + if (mount | grep -q "$MOUNT_POINT"); then echo -e "${BLUE} [o] ${MOUNT_POINT} is mounted...${END}" - df -h | grep $MOUNT_POINT + df -h | grep "$MOUNT_POINT" else echo -e "${RED} [x] ${MOUNT_POINT} is not currently mounted...${END}" fi From 400e0aed7d1981cecf14f91f68bebb217117c4b9 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Thu, 26 Jan 2023 13:21:20 +0000 Subject: [PATCH 3/5] :arrow_up: Allow Powershell 7.2.8 --- deployment/CheckRequirements.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/CheckRequirements.ps1 b/deployment/CheckRequirements.ps1 index 2e8f24d6d9..f3dce22c3a 100644 --- a/deployment/CheckRequirements.ps1 +++ b/deployment/CheckRequirements.ps1 @@ -9,7 +9,7 @@ Import-Module $PSScriptRoot/common/Logging -Force -ErrorAction Stop # Requirements $PowershellMinVersion = "7.0.0" -$PowershellMaxVersion = "7.2.7" +$PowershellMaxVersion = "7.2.8" $ModuleVersionRequired = @{ "Az.Accounts" = @("ge", "2.9.0") "Az.Automation" = @("ge", "1.7.3") From 89b988cbd3293f176bf913636f00127d7a67ce11 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Thu, 26 Jan 2023 15:57:14 +0000 Subject: [PATCH 4/5] :recycle: Use findmnt to get disk size Co-authored-by: Jim Madge --- .../cloud_init/cloud-init-srd.mustache.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml b/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml index 91ccd18d14..12065238e6 100644 --- a/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml +++ b/deployment/secure_research_environment/cloud_init/cloud-init-srd.mustache.yaml @@ -415,7 +415,7 @@ write_files: BLOBFUSE_CACHE_DIR="/tmp/blobfuse-cache-backup" rm -rf $BLOBFUSE_CACHE_DIR mkdir -p $BLOBFUSE_CACHE_DIR - CACHE_SPACE_MB=$(echo "$(df -BM | grep /dev/root | awk '{print $2}' | sed 's/M//') / 50" | bc) # set the cache size to 2% of the OS disk size + CACHE_SPACE_MB=$(echo "$(findmnt -nb -o size /) / 1024^2 / 50" | bc) # set the cache size to 2% of the OS disk size /usr/bin/blobfuse $1 -o rw --tmp-path=$BLOBFUSE_CACHE_DIR --cache-size-mb=$CACHE_SPACE_MB --no-symlinks=true --config-file=/opt/configuration/credentials-backup.secret --log-level=LOG_DEBUG -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other fi @@ -426,7 +426,7 @@ write_files: BLOBFUSE_CACHE_DIR="/tmp/blobfuse-cache-egress" rm -rf $BLOBFUSE_CACHE_DIR mkdir -p $BLOBFUSE_CACHE_DIR - CACHE_SPACE_MB=$(echo "$(df -BM | grep /dev/root | awk '{print $2}' | sed 's/M//') / 50" | bc) # set the cache size to 2% of the OS disk size + CACHE_SPACE_MB=$(echo "$(findmnt -nb -o size /) / 1024^2 / 50" | bc) # set the cache size to 2% of the OS disk size /usr/bin/blobfuse $1 -o rw --tmp-path=$BLOBFUSE_CACHE_DIR --cache-size-mb=$CACHE_SPACE_MB --no-symlinks=true --config-file=/opt/configuration/credentials-egress.secret --log-level=LOG_DEBUG -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other fi @@ -437,7 +437,7 @@ write_files: BLOBFUSE_CACHE_DIR="/tmp/blobfuse-cache-ingress" rm -rf $BLOBFUSE_CACHE_DIR mkdir -p $BLOBFUSE_CACHE_DIR - CACHE_SPACE_MB=$(echo "$(df -BM | grep /dev/root | awk '{print $2}' | sed 's/M//') / 50" | bc) # set the cache size to 2% of the OS disk size + CACHE_SPACE_MB=$(echo "$(findmnt -nb -o size /) / 1024^2 / 50" | bc) # set the cache size to 2% of the OS disk size /usr/bin/blobfuse $1 -o ro --tmp-path=$BLOBFUSE_CACHE_DIR --cache-size-mb=$CACHE_SPACE_MB --no-symlinks=true --config-file=/opt/configuration/credentials-ingress.secret --log-level=LOG_DEBUG -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o allow_other fi From 24951259244ffd9dd17357e067ceef2539ef3ddd Mon Sep 17 00:00:00 2001 From: James Robinson Date: Thu, 26 Jan 2023 16:04:06 +0000 Subject: [PATCH 5/5] :recycle: Use findmnt to check whether targets are mounted --- .../secure_research_desktop/scripts/check_drive_mounts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh b/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh index ece5f457ae..eb1a7b606c 100644 --- a/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh +++ b/deployment/secure_research_environment/remote/secure_research_desktop/scripts/check_drive_mounts.sh @@ -11,7 +11,7 @@ MOUNT_POINTS=("/data" "/home" "/scratch" "/shared" "/output") echo -e "${BLUE}Checking drives are mounted...${END}" for MOUNT_POINT in "${MOUNT_POINTS[@]}"; do ls "${MOUNT_POINT}"/* > /dev/null 2>&1 - if (mount | grep -q "$MOUNT_POINT"); then + if (findmnt "$MOUNT_POINT" > /dev/null 2>&1); then echo -e "${BLUE} [o] ${MOUNT_POINT} is mounted...${END}" else echo -e "${RED} [ ] ${MOUNT_POINT} not mounted. Attempting to mount...${END}" @@ -28,7 +28,7 @@ sleep 30 echo -e "${BLUE}Rechecking drives are mounted...${END}" for MOUNT_POINT in "${MOUNT_POINTS[@]}"; do ls "${MOUNT_POINT}"/* > /dev/null 2>&1 - if (mount | grep -q "$MOUNT_POINT"); then + if (findmnt "$MOUNT_POINT" > /dev/null 2>&1); then echo -e "${BLUE} [o] ${MOUNT_POINT} is mounted...${END}" df -h | grep "$MOUNT_POINT" else