@@ -254,7 +254,7 @@ if [[ ${LIST_REPOS} -eq 1 ]]; then
254254 default_label=" , default"
255255 else
256256 default_label=" "
257- fi
257+ fi
258258 echo " ${cvmfs_repo} [CVMFS config repo${default_label} ]"
259259 done
260260 for cfg_repo in " ${! cfg_cvmfs_repos[@]} "
323323 if [[ ! -n " ${eessi_cvmfs_repos[${cvmfs_repo_name}]} " ]] ; then
324324 [[ ${VERBOSE} -eq 1 ]] && echo " repo '${cvmfs_repo_name} ' is not an EESSI CVMFS repository..."
325325 # cvmfs_repo_name is actually a repository ID, use that to obtain
326- # the actual name from the EESSI_REPOS_CFG_FILE
326+ # the actual name from the EESSI_REPOS_CFG_FILE
327327 cfg_repo_id=${cvmfs_repo_name}
328328 cvmfs_repo_name=$( cfg_get_value ${cfg_repo_id} " repo_name" )
329329 fi
595595 # that the necessary information for accessing a CVMFS repository is made
596596 # available inside the container
597597 if [[ -n " ${cfg_cvmfs_repos[${cvmfs_repo_name}]} " ]] ; then
598- cfg_repo_id=${cvmfs_repo_name}
598+ cfg_repo_id=${cvmfs_repo_name}
599599
600- # obtain CVMFS repository name from section for the given ID
600+ # obtain CVMFS repository name from section for the given ID
601601 cfg_repo_name=$( cfg_get_value ${cfg_repo_id} " repo_name" )
602- # derive domain part from (cfg_)repo_name (everything after first '.')
602+ # derive domain part from (cfg_)repo_name (everything after first '.')
603603 repo_name_domain=${repo_name#* .}
604604
605605 # cfg_cvmfs_repos is populated through reading the file pointed to by
609609 # copy repos.cfg to job directory --> makes it easier to inspect the job
610610 cp -a ${EESSI_REPOS_CFG_FILE} ${EESSI_TMPDIR} /repos_cfg/.
611611
612- # cfg file should include sections (one per CVMFS repository to be mounted)
613- # with each section containing the settings:
614- # - repo_name,
615- # - repo_version,
616- # - config_bundle, and
617- # - a map { filepath_in_bundle -> container_filepath }
612+ # cfg file should include sections (one per CVMFS repository to be mounted)
613+ # with each section containing the settings:
614+ # - repo_name,
615+ # - repo_version,
616+ # - config_bundle, and
617+ # - a map { filepath_in_bundle -> container_filepath }
618618 #
619- # The config_bundle includes the files which are mapped ('->') to a target
620- # location in container:
619+ # The config_bundle includes the files which are mapped ('->') to a target
620+ # location in container:
621621 # - default.local -> /etc/cvmfs/default.local
622622 # contains CVMFS settings, e.g., CVMFS_HTTP_PROXY, CVMFS_QUOTA_LIMIT, ...
623623 # - ${repo_name_domain}.conf -> /etc/cvmfs/domain.d/${repo_name_domain}.conf
641641 # use information to set up dir ${EESSI_TMPDIR}/repos_cfg and define
642642 # BIND mounts
643643 # check if config_bundle exists, if so, unpack it into
644- # ${EESSI_TMPDIR}/repos_cfg; if it doesn't, exit with an error
644+ # ${EESSI_TMPDIR}/repos_cfg; if it doesn't, exit with an error
645645 # if config_bundle is relative path (no '/' at start) prepend it with
646646 # EESSI_REPOS_CFG_DIR
647647 config_bundle_path=
726726 if [[ ${cfg_cvmfs_repos[${cvmfs_repo_name}]} ]]; then
727727 [[ ${VERBOSE} -eq 1 ]] && echo " repo '${cvmfs_repo_name} ' is not an EESSI CVMFS repository..."
728728 # cvmfs_repo_name is actually a repository ID, use that to obtain
729- # the actual name from the EESSI_REPOS_CFG_FILE
729+ # the actual name from the EESSI_REPOS_CFG_FILE
730730 cfg_repo_id=${cvmfs_repo_name}
731731 cvmfs_repo_name=$( cfg_get_value ${cfg_repo_id} " repo_name" )
732732 fi
736736
737737 # add fusemount options depending on requested access mode ('ro' - read-only; 'rw' - read & write)
738738 if [[ ${cvmfs_repo_access} == " ro" ]] ; then
739- export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name} "
739+ # need to distinguish between basic "ro" access and "ro" after a "rw" session
740+ if [[ -d ${EESSI_TMPDIR} /${cvmfs_repo_name} /overlay-upper ]]; then
741+ # the overlay-upper directory is only created in a read-write-session, thus
742+ # we are resuming from such a session here (otherwise there shouldn't be such
743+ # directory yet as it is only created for read-write-sessions a bit further
744+ # below); the overlay-upper directory can only exist because it is part of
745+ # the ${RESUME} directory or tarball
746+ # to be able to see the contents of the read-write session we have to mount
747+ # the fuse-overlayfs (in read-only mode) on top of the CernVM-FS repository
748+
749+ echo " While processing '${cvmfs_repo_name} ' to be mounted 'read-only' we detected an overlay-upper"
750+ echo " directory (${EESSI_TMPDIR} /${cvmfs_repo_name} /overlay-upper) likely from a previous"
751+ echo " session. Will use it as left-most directory in 'lowerdir' argument for fuse-overlayfs."
752+
753+ # make the target CernVM-FS repository available under /cvmfs_ro
754+ export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name} "
755+
756+ EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
757+
758+ # now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs
759+ EESSI_READONLY_OVERLAY=" container:fuse-overlayfs"
760+ # The contents of the previous session are available under
761+ # ${EESSI_TMPDIR} which is bind mounted to ${TMP_IN_CONTAINER}.
762+ # Hence, we have to use ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper
763+ # the left-most directory given for the lowerdir argument is put on top,
764+ # and with no upperdir=... the whole overlayfs is made available read-only
765+ EESSI_READONLY_OVERLAY+=" -o lowerdir=${TMP_IN_CONTAINER} /${cvmfs_repo_name} /overlay-upper:/cvmfs_ro/${cvmfs_repo_name} "
766+ EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name} "
767+ export EESSI_READONLY_OVERLAY
768+
769+ EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY_OVERLAY} " )
770+ export EESSI_FUSE_MOUNTS
771+ else
772+ # basic "ro" access that doesn't require any fuseoverlay-fs
773+ echo " Mounting '${cvmfs_repo_name} ' 'read-only' without fuse-overlayfs."
740774
741- EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
742- export EESSI_FUSE_MOUNTS
775+ export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name} "
776+
777+ EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
778+ export EESSI_FUSE_MOUNTS
779+ fi
743780 elif [[ ${cvmfs_repo_access} == " rw" ]] ; then
744781 # use repo-specific overlay directories
745782 mkdir -p ${EESSI_TMPDIR} /${cvmfs_repo_name} /overlay-upper
746783 mkdir -p ${EESSI_TMPDIR} /${cvmfs_repo_name} /overlay-work
747- [[ ${VERBOSE} -eq 1 ]] && echo -e " TMP directory contents:\n$( ls -l ${EESSI_TMPDIR} ) "
784+ [[ ${VERBOSE} -eq 1 ]] && echo -e " TMP directory contents:\n$( ls -l ${EESSI_TMPDIR} ) "
748785
749786 # set environment variables for fuse mounts in Singularity container
750787 export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name} "
762799 export EESSI_FUSE_MOUNTS
763800 else
764801 echo -e " ERROR: access mode '${cvmfs_repo_access} ' for CVMFS repository\n '${cvmfs_repo_name} ' is not known"
765- exit ${REPOSITORY_ERROR_EXITCODE}
802+ exit ${REPOSITORY_ERROR_EXITCODE}
766803 fi
767804 # create repo_settings.sh file in ${EESSI_TMPDIR}/${cvmfs_repo_name} to store
768805 # (intention is that the file could be just sourced to obtain the settings)
0 commit comments