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

Improve dynamic port selection #1494

Closed
wants to merge 13 commits into from
Closed

Improve dynamic port selection #1494

wants to merge 13 commits into from

Conversation

bagelswitch
Copy link

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).

@dadgar
Copy link
Contributor

dadgar commented Aug 3, 2016

I think it may be simpler if we do the computation as follows:

a := []Ports{Port Range - node.Reserved - ask.Reserved}
shuffle(a)
dynamic ports := a[:len(ask.DynamicPorts)]

I think this code will be simpler and have a better run time cost. And then we can remove the maxAttempts

@bagelswitch
Copy link
Author

Thanks @dadgar - something more like this?

@dadgar
Copy link
Contributor

dadgar commented Aug 5, 2016

Closing in favor of #1526

Thanks for finding and bringing this up!

@dadgar dadgar closed this Aug 5, 2016
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2023
@pkazmierczak pkazmierczak removed their assignment Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants