From cdeb8df04e2abd67f3ed68b8500d8dad1dbd7c43 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 8 May 2023 11:51:58 +0200 Subject: [dnbd3-proxy-mode] Dynamic deletion delay based on RTC If the proxy is being started up mid-day, it might be undesired to have it wait for 18 hours before deleting old images. This might mean we don't have a good idea which image has been unused longest, but it's better to delete *some* unused image than just not replicating any images at all. --- .../data/opt/openslx/scripts/systemd-setup_dnbd3_proxy | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'core/modules') diff --git a/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy b/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy index 04cc9ba4..96d62ae4 100755 --- a/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy +++ b/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-setup_dnbd3_proxy @@ -160,7 +160,19 @@ else DNBD3_BGR="false" DNBD3_BGR_MIN_CLIENTS=0 DNBD3_LOOKUP="false" - DNBD3_AUTOFREE="18h" + # Delay deletion only if we're booted early + hour="$( date +%_H )" + hour="${hour# }" + if [ "$hour" -lt 7 ]; then + DNBD3_AUTOFREE=$(( 7 - hour )) + else + DNBD3_AUTOFREE=0 + fi + # Wait some more on Sunday + if [ "$( date +%w )" = 0 ]; then + DNBD3_AUTOFREE=$(( DNBD3_AUTOFREE + 18 )) + fi + DNBD3_SERVER_PENALTY=3000 # no BGR = don't like other servers connecting so much if [ -n "${SLX_DNBD3_BGR}" ]; then DNBD3_BGR="true" @@ -244,7 +256,7 @@ removeMissingImages=false uplinkTimeout=5000 clientTimeout=15000 pretendClient=${DNBD3_PRETEND_CLIENT} -autoFreeDiskSpaceDelay=${DNBD3_AUTOFREE} +autoFreeDiskSpaceDelay=${DNBD3_AUTOFREE}h [limits] maxPayload=10M -- cgit v1.2.3-55-g7522