From df0665b6def8ca0758980042e06f7d59b821938a Mon Sep 17 00:00:00 2001 From: Tanmay Naik Date: Sat, 3 Feb 2024 00:28:43 +0000 Subject: [PATCH] oci: resolve cross-filesystem blob caching failure This commit addresses an issue in the OCI template where lxc-create fails if OCI-cache directory for blob caching is not on the same mount as the destination OCI directory. lxc-create bails when skopeo tries to create a hard-link across the two and fails. For example, if /var/lib/lxc is a bind mountpoint of a random directory and skopeo fails to hard-link across /var/cache/lxc and /var/lib/lxc This commit introduces a check where if both directories are on not the same mount points, it disables blob caching in skopeo and continues. Signed-off-by: Tanmay Naik --- templates/lxc-oci.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/templates/lxc-oci.in b/templates/lxc-oci.in index 298d3e06e..9b9abff2e 100755 --- a/templates/lxc-oci.in +++ b/templates/lxc-oci.in @@ -223,6 +223,18 @@ getcwd() { return } +is_same_mountpoint() { + local path1="$1" + local path2="$2" + local mount1 + local mount2 + + # make sure bind mounts are covered + mount1=$(df --output=target "$path1" | tail -n 1) + mount2=$(df --output=target "$path2" | tail -n 1) + [ "$mount1" = "$mount2" ] +} + usage() { cat <