Commit 5b6a62a5 authored by Gonzalo S Nido's avatar Gonzalo S Nido
Browse files

Added resizing of small results file share

parent f1f7fb04
......@@ -26,6 +26,11 @@ usage()
echo " --strategies STRATEGIES"
echo " Only run selected strategies. Possible choices of STRATEGIES: "1", "2", "3""
echo " or any combination of them, comma-separated (e.g. "1,2,3", "2,3")."
echo " --shrink-fileshare"
echo " When finished, reduce quota of fileshare to be only 10G more than the total"
echo " space needed for the results. This option is not to be used when other tasks"
echo " are running on the same fileshare (e.g. when running different strategies"
echo " concomitantly."
echo " --input-samba-credentials FILE"
echo " File with the samba credentials to mount input fileshare (fastqs)."
echo " --output-samba-credentials FILE"
......@@ -48,6 +53,7 @@ FORCE=0
MONITOR=0
SUBSET=0
STRATEGIES="1,2,3"
SHRINK=0
smbCredFastq=
smbCredResults=
......@@ -81,6 +87,8 @@ while [ "$1" != "" ]; do
--strategies ) shift
STRATEGIES=$1
;;
--shrink-fileshare ) SHRINK=1
;;
-h | --help ) usage
exit
;;
......@@ -147,6 +155,7 @@ echo "- FORCE: $FORCE"
echo "- MONITOR: $MONITOR"
echo "- SUBSET: $SUBSET"
echo "- STRATEGIES: ${STRATEGIES}"
echo "- SHRINK: ${SHRINK}"
echo
echo "ACTUALLY DOING STUFF"
......@@ -209,20 +218,32 @@ echo " *Input FASTQ file share mounted in \"${fastq_folder}\""
echo ">> Preparing output file share... "
# Check that results fileshare does NOT exist or issue warning and wait
exists=$( az storage share exists --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} --name "${shareNameResults}" --output tsv )
if [[ $exists == "True" && $FORCE == 0 ]]; then
echo " [ERROR] File share \"${shareNameResults}\" in \"${storageAccountResults}\" ALREADY EXISTS!"
echo " To overwrite, use -f option"
if [[ $exists == "False" ]]; then
az storage share create \
--account-name ${storageAccountResults} \
--account-key ${storageAccountKeyResults} \
--name "${shareNameResults}" \
--quota 3072 \
--output none
else
if [[ $FORCE == 0 ]]; then
echo " [ERROR] File share \"${shareNameResults}\" in \"${storageAccountResults}\""
echo " ALREADY EXISTS!"
echo " If you don't mind potentially overwriting, use -f option"
exit 2
else
quota=$( az storage share show --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} --name "${shareNameResults}" --output json --query properties.quota )
if [[ $quota < 3072 ]]; then
echo " [WARNING] File share \"${shareNameResults}\" in \"${storageAccountResults}\""
echo " has a quota smaller than 3072G, resizing to 3072..."
az storage share update --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} --name "${shareNameResults}" --quota 3072
fi
fi
fi
results_folder="/fileshares/${storageAccountResults}/${shareNameResults}"
# Create it
az storage share create \
--account-name ${storageAccountResults} \
--account-key ${storageAccountKeyResults} \
--name "${shareNameResults}" \
--quota 3072 \
--output none
sudo mkdir -p ${results_folder}
......@@ -303,16 +324,22 @@ echo
echo "**************FINISHED**************"
echo
# Get space used by files in share in GB
sleep 30
size1=$( az storage share stats --name ${shareNameResults} --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} )
size2=$( du -sh -BG ${results_folder} | cut -f 1 | tr -d 'G' )
size=$(( size1 > size2 ? size1 + 10 : size2 + 10))
echo " Output files use around $(( size - 10 )) G"
echo " Resizing fileshare quota to $size..."
az storage share update --name ${shareNameResults} --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} --quota ${size}
# Resize storage file share (CAREFUL IF OTHER TASKS NEED THE SPACE!)
if [[ $SHRINK > 0 ]]; then
echo ">> Shrinking the fileshare..."
# Get space used by files in share in GB
sleep 30
size1=$( az storage share stats --name ${shareNameResults} --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} )
size2=$( du -sh -BG ${results_folder} | cut -f 1 | tr -d 'G' )
size=$(( size1 > size2 ? size1 + 10 : size2 + 10))
echo " Output files use around $(( size - 10 )) G"
echo " Resizing fileshare quota to $size G..."
az storage share update --name ${shareNameResults} --account-name ${storageAccountResults} --account-key ${storageAccountKeyResults} --quota ${size}
else
echo " * Fileshare in storage account left with 3G quota"
fi
echo
cd ~
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment