Skip to content

Commit

Permalink
load_contact_file: refresh NFS cache for directories above contact file
Browse files Browse the repository at this point in the history
* See #6506
  • Loading branch information
oliver-sanders committed Feb 11, 2025
1 parent 890825c commit 0352a86
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cylc/flow/workflow_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ def get_workflow_srv_dir(id_):


def load_contact_file(id_: str, run_dir=None) -> Dict[str, str]:
"""Load contact file. Return data as key=value dict."""
if not run_dir:
path = Path(get_contact_file_path(id_))
else:
Expand All @@ -630,6 +629,19 @@ def load_contact_file(id_: str, run_dir=None) -> Dict[str, str]:
WorkflowFiles.Service.DIRNAME,
WorkflowFiles.Service.CONTACT
)

# refresh NFS cache before proceeding, the contact file might magically
# appear, see https://github.com/cylc/cylc-flow/issues/6506
if not path.exists():
# list all directories between ~/cylc-run and the the workflow
# run dir (inclusive)
cylc_run_dir = get_cylc_run_dir()
for subdir in reversed(path.relative_to(cylc_run_dir).parents):
try:
list((cylc_run_dir / subdir).iterdir())
except FileNotFoundError as exc:
raise ServiceFileError("Couldn't load contact file") from exc

try:
with open(path) as f:
file_content = f.read()
Expand Down

0 comments on commit 0352a86

Please sign in to comment.