-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Improve dynamic port selection #1494
Conversation
I think it may be simpler if we do the computation as follows:
I think this code will be simpler and have a better run time cost. And then we can remove the maxAttempts |
Thanks @dadgar - something more like this? |
Closing in favor of #1526 Thanks for finding and bringing this up! |
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
The way that dynamic port assignment is done currently doesn't work well at all if significant ranges of reserved_ports are specified in nomad client config. For example:
client {
reserved {
reserved_ports = "23000-65535"
}
}
With this config (which leaves ports 20000-22999 available for assignment), running a job requiring several dynamic ports will fail more often than not, as a random pick in the range 20000-60000 will fall in a reserved range >90% of the time.
This change ensures that acceptable ports are always assigned, so long as a sufficient number of free ports exist in any non-reserved range between MinDynamicPort (20000) and MaxDynamicPort (60000).