From 3a7656015ffe39e7167b11657c6691d7609a0db5 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Mon, 5 May 2025 19:21:10 -0400 Subject: [PATCH] check/create volume toplink in add_volume --- kojihub/kojihub.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py index 69e17767..a7a5fc2d 100644 --- a/kojihub/kojihub.py +++ b/kojihub/kojihub.py @@ -6116,6 +6116,22 @@ def add_volume(name, strict=True): voldir = koji.pathinfo.volumedir(name) if not os.path.isdir(voldir): raise koji.GenericError('please create the volume directory first') + + # volume directories should have a symlink to default volume, e.g. /mnt/koji + toplink = joinpath(voldir, 'toplink') + if os.path.islink(toplink): + if not os.path.exists(toplink): + raise koji.GenericError(f'Broken volume toplink: {toplink}') + if not os.path.samefile(toplink, koji.pathinfo.topdir): + raise koji.GenericError(f'Invalid volume toplink: {toplink}') + elif os.path.exists(toplink): + # not a link + raise koji.GenericError(f'Not a symlink: {toplink}') + else: + target = koji.pathinfo.topdir + logger.warning('No toplink for volume. Creating {toplink} -> {target}') + os.symlink(target, toplink) + if strict: volinfo = lookup_name('volume', name, strict=False) if volinfo: