From 9e622d3e4de9035c9f4b6ad3653a1fdc99d424dd Mon Sep 17 00:00:00 2001 From: "J. Daniel Schmidt" Date: Tue, 14 May 2019 11:15:16 +0200 Subject: [PATCH] mkcloud: improve image cache usage In order to prevent the image cache directory to fill up the disk the cache should share its images with all jobs. A 'per' job cache does not make sense for an image thats just used once. So the value of $cache_dir_default is now a shared directory and no longer contains the cloud name. To not break running deployments rsync needs to drop the 'inplace' parameter, so that it first syncs the new image and then does a rename at the end. This guarantees that 1) there is always one consistent image to deploy from, 2) no running jobs read from currupt files, 3) the cache really caches for all jobs on the host. The compress parameter can also be dropped because the image files are already compressed. So we can save CPU cycles. --- scripts/lib/mkcloud-driver-libvirt.sh | 2 +- scripts/mkcloud | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib/mkcloud-driver-libvirt.sh b/scripts/lib/mkcloud-driver-libvirt.sh index f45ac76788..87383bf8b0 100644 --- a/scripts/lib/mkcloud-driver-libvirt.sh +++ b/scripts/lib/mkcloud-driver-libvirt.sh @@ -385,7 +385,7 @@ function libvirt_do_onhost_deploy_image() if [[ ! $want_cached_images = 1 ]] ; then [ -n $rsyncserver_fqdn ] || complain 95 "Missing RSYNC Server FQDN!" - safely rsync --compress --progress --inplace --archive --verbose \ + safely rsync --progress --archive --verbose \ rsync://$rsyncserver_fqdn/$rsyncserver_images_dir/$image $cache_dir/ else # In this case the image has to be supplied by other means than diff --git a/scripts/mkcloud b/scripts/mkcloud index ef45fcece1..d372473113 100755 --- a/scripts/mkcloud +++ b/scripts/mkcloud @@ -29,7 +29,7 @@ if [[ $debug_mkcloud = 1 ]] ; then PS4='+(${BASH_SOURCE##*/}:${LINENO}) ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' fi -cache_dir_default=/var/cache/mkcloud/$cloud +cache_dir_default=/var/cache/mkcloud [[ $UID != 0 ]] && cache_dir_default="${XDG_CACHE_HOME:-./cache}/mkcloud" : ${cache_dir:=$cache_dir_default} mkdir -p "$cache_dir"