Skip to content

Commit

Permalink
mkcloud: improve image cache usage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jdsn committed May 14, 2019
1 parent 5d83779 commit 9e622d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/lib/mkcloud-driver-libvirt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/mkcloud
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9e622d3

Please sign in to comment.