Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make app more robust against current-directory index-number changes #1483

Closed
tcompa opened this issue May 13, 2024 · 2 comments · Fixed by #1497
Closed

Make app more robust against current-directory index-number changes #1483

tcompa opened this issue May 13, 2024 · 2 comments · Fixed by #1497
Assignees

Comments

@tcompa
Copy link
Collaborator

tcompa commented May 13, 2024

The most likely explanation we found for #1478 was a change in the current-working-directory index number, probably due to an export of the NFS shares where fractal-server runs. Note that we cannot verify the old index number any more.

This scenario is not expected, but we can still partly mitigate it. The specific issue in #1478 was with the Path.resolve function, which then calls os.getcwd() as part of its internals. We use resolve() in very few modules, and it's likely that we could always replace it with as_posix() remove it (or, when we cannot, these are parts of the code that would probably run at startup - when the folder definitely hasn't changed index number yet). This change would mitigate the issue in #1478.


To debug:

  • cd into a temporary folder tmp1 and start fractal-server from there (first take a note of the results of ls -ila, where -i prints the index number)
  • From a different terminal: cd .., cp -r tmp1 tmp2, rm -r tmp1, mv tmp2 tmp1. If we now cd into tmp1 and run ls -ila, we'll find a different index number
  • Keep interacting with fractal-server, and see what goes wrong.

If we find other parts of the code that rely on the current working directory, we should check whether it's easy to replace them with equivalent robust versions.


Higher level advice:

  1. It's best to run the application from a very stable mount (e.g. an attached ext4 volume)
  2. System-side, one should consider NFS re-exports as potentially breaking
@ychiucco
Copy link
Collaborator

With upcoming pull request, we solved the error from #1478 but we found a similar error related to Task collection (collecting fractal-tasks-core with pip):

Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 196, in _run_module_as_main\n    return _run_code(code, main_globals, None,\n  File \"/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/Users/yuri/Library/Caches/pypoetry/virtualenvs/fractal-server-zZ2T8p1a-py3.10/lib/python3.10/site-packages/pip/__main__.py\", line 8, in <module>\n    if sys.path[0] in (\"\", os.getcwd()):\nFileNotFoundError: [Errno 2] No such file or directory\n")
Invalid package or manifest. Original error: Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/yuri/Library/Caches/pypoetry/virtualenvs/fractal-server-zZ2T8p1a-py3.10/lib/python3.10/site-packages/pip/__main__.py", line 8, in <module>
    if sys.path[0] in ("", os.getcwd()):
FileNotFoundError: [Errno 2] No such file or directory

@ychiucco ychiucco mentioned this issue May 15, 2024
2 tasks
@ychiucco ychiucco linked a pull request May 15, 2024 that will close this issue
2 tasks
@tcompa
Copy link
Collaborator Author

tcompa commented May 15, 2024

With upcoming pull request, we solved the error from #1478 but we found a similar error related to Task collection (collecting fractal-tasks-core with pip):

Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 196, in _run_module_as_main\n    return _run_code(code, main_globals, None,\n  File \"/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/Users/yuri/Library/Caches/pypoetry/virtualenvs/fractal-server-zZ2T8p1a-py3.10/lib/python3.10/site-packages/pip/__main__.py\", line 8, in <module>\n    if sys.path[0] in (\"\", os.getcwd()):\nFileNotFoundError: [Errno 2] No such file or directory\n")
Invalid package or manifest. Original error: Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/yuri/Library/Caches/pypoetry/virtualenvs/fractal-server-zZ2T8p1a-py3.10/lib/python3.10/site-packages/pip/__main__.py", line 8, in <module>
    if sys.path[0] in ("", os.getcwd()):
FileNotFoundError: [Errno 2] No such file or directory

For the record, we are not currently covering this one as part of #1497.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants