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

Set difference when picking random ports #1526

Merged
merged 4 commits into from
Aug 10, 2016
Merged

Set difference when picking random ports #1526

merged 4 commits into from
Aug 10, 2016

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Aug 5, 2016

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

Thanks to @bagelswitch for reporting.

@armon for review

}

s := b.Size()
for i := uint(0); i < s; i++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would copy full bytes at a time not bits. You have access to the underlying byte array, and there is no need to add a conditional set.

@armon
Copy link
Member

armon commented Aug 10, 2016

left some comments, LGTM

@dadgar dadgar merged commit 69c1cc4 into master Aug 10, 2016
@dadgar dadgar deleted the b-random-ports branch August 10, 2016 23:37
@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
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

2 participants