Skip to content
Snippets Groups Projects
Commit 72248270 authored by MAAP System's avatar MAAP System
Browse files

Auto remount sf3s on failure

parent 1df6df2b
No related branches found
No related tags found
No related merge requests found
Pipeline #414 passed with stage
in 1 second
......@@ -47,6 +47,11 @@ WORKDIR /projects
COPY *.sh /usr/local/bin/
ADD crontab.txt /crontab.txt
ADD cron_script.sh /cron_script.sh
RUN chmod 755 /cron_script.sh
RUN /usr/bin/crontab /crontab.txt
# The default is to perform all system-level mounting as part of the entrypoint
# to then have a command that will keep listing the files under the main share.
# Listing the files will keep the share active and avoid that the remote server
......
#!/bin/sh
urlencode() {
python - <<END
from urllib.parse import quote
import os
api_host = os.environ.get('CHE_API_EXTERNAL')
# double-encode url
print(quote(quote(api_host, safe=""), safe=""))
END
}
CHE_API_URL_ENCODED=$(urlencode)
# TODO: Update the API url after deployment!
MAAP_ENV=$(curl -s https://api.ops.maap-project.org/api/environment/bucketPrefix/${CHE_API_URL_ENCODED} | tr -d '"')
check_dir () {
if [ ! -d $1 ]; then
echo "$1 does not exist. Unmounting..."
fusermount -u $1
echo "Remounting $1..."
s3fs maap-$MAAP_ENV-workspace:$2 $1 -o use_cache=/scratch$2 -o imdsv1only -o iam_role=auto
fi
}
check_dir /my-private-bucket /$CHE_WORKSPACE_NAMESPACE
check_dir /shared-buckets /shared
check_dir /my-public-bucket /shared/$CHE_WORKSPACE_NAMESPACE
* * * * * /cron_script.sh >> /var/log/cron_script.log
\ No newline at end of file
......@@ -22,11 +22,18 @@ mkdir -p /s3root/shared/$CHE_WORKSPACE_NAMESPACE
umount /s3root
rm -rf /s3root
# Create temp directory
mkdir /scratch && mkdir /scratch/$CHE_WORKSPACE_NAMESPACE
mount_dir () {
# Create temp directory
mkdir /scratch && mkdir /scratch$2
echo "Mounting $1..."
s3fs maap-$MAAP_ENV-workspace:$2 $1 -o use_cache=/scratch$2 -o imdsv1only -o iam_role=auto
}
mount_dir /my-private-bucket /$CHE_WORKSPACE_NAMESPACE
mount_dir /shared-buckets /shared
mount_dir /my-public-bucket /shared/$CHE_WORKSPACE_NAMESPACE
s3fs maap-$MAAP_ENV-workspace:/$CHE_WORKSPACE_NAMESPACE /my-private-bucket -o use_cache=/scratch/$CHE_WORKSPACE_NAMESPACE -o imdsv1only -o iam_role=auto
s3fs maap-$MAAP_ENV-workspace:/shared /shared-buckets -o ro -o use_cache=/scratch/$CHE_WORKSPACE_NAMESPACE -o imdsv1only -o iam_role=auto
s3fs maap-$MAAP_ENV-workspace:/shared/$CHE_WORKSPACE_NAMESPACE /my-public-bucket -o use_cache=/scratch/$CHE_WORKSPACE_NAMESPACE -o imdsv1only -o iam_role=auto
# start cron
/usr/sbin/crond -f -l 8
tail -f /dev/null
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment