From a174a46e02406429e529847263e3bfec0c0ea2c6 Mon Sep 17 00:00:00 2001 From: Devin Petersohn Date: Thu, 20 Dec 2018 18:46:54 -0800 Subject: [PATCH] Allowing multiple users to access the /tmp/ray file at the same time (#3591) * Allowing multiple users to access the /tmp/ray file at the same time Previous sequence that caused this issue: * User A starts ray with `ray.init` when /tmp/ray does not exist * User B starts ray with `ray.init` and /tmp/ray now exists User B will get a permissions error Checking the permissions, /tmp/ray is 700 I have identified a race condition in `try_to_create_directory` * Multiple processes try to create /tmp/ray at the same time * chmod is either silently erroring or working properly within the race condition Resolution: Move chmod outside of the check for whether the directory exists or not. * Adding try except for users who do not own the directory --- python/ray/tempfile_services.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/ray/tempfile_services.py b/python/ray/tempfile_services.py index d4e94aec8..791b8a257 100644 --- a/python/ray/tempfile_services.py +++ b/python/ray/tempfile_services.py @@ -64,7 +64,10 @@ def try_to_create_directory(directory_path): "exists.".format(directory_path)) # Change the log directory permissions so others can use it. This is # important when multiple people are using the same machine. + try: os.chmod(directory_path, 0o0777) + except PermissionError: + pass def get_temp_root():