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

Need better handler for tmp files to unblock running under different users #397

Open
FFAMax opened this issue Oct 28, 2024 · 4 comments
Open

Comments

@FFAMax
Copy link
Contributor

FFAMax commented Oct 28, 2024

used_ports_file = os.path.join(tempfile.gettempdir(), "exo_used_ports")

If user A used exo, user B will unable to use exo due tmp file blocked by user A until manually removed or system reloaded (in cases tmp folder wiped during reload)

@AlexCheema
Copy link
Contributor

I'm not sure what you mean by this.

@FFAMax
Copy link
Contributor Author

FFAMax commented Oct 30, 2024

exo_used_ports

In tmp dir will be created file exo_used_ports. Once another user wanna use exo, file is there and cause user can't use

@dtnewman
Copy link
Contributor

dtnewman commented Nov 3, 2024

@AlexCheema some further discussion of this in #396. On a linux machine, let's say User 1 creates a file in /tmp folder to store ports. Now User 2 comes along and tries to read/write to the same file, but gets an error, since the file is only modifiable by user 1.

I think the solution here might be to just simplify the find_available_port function. I'm not 100% sure what the thinking is behind persisting the recently used ports, instead of just poking around and trying to find a random port that's available in the given range (which should be fairly trivial... i'd assume in the vast majority of cases, if you randomly select in the given range (49152 to 65535) it will find an available port on the first or second try. Is the issue that you might collide with a port used by another machine in the network?

@FFAMax
Copy link
Contributor Author

FFAMax commented Nov 3, 2024

Is the issue that you might collide with a port used by another machine in the network?

I don't think it may interfere with another machine on the network because machines may have the same ports while they are sitting on different addresses.

available_ports = set(range(min_port, max_port + 1)) - set(used_ports)
Probably it was used to reduce iterations when looking for another port to open a new socket.

I don't see the issue if just try to bind next available port regardless of what written in the file.
I see only one call of this function in main.py
if args.node_port is None: args.node_port = find_available_port(args.node_host)

Also can introduce and stick to default port, fallback to random if default already used.

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

No branches or pull requests

3 participants