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

Dynamic port range support (fixes issue #1384) #2135

Closed
wants to merge 2 commits into from

Conversation

capone212
Copy link
Contributor

@capone212 capone212 commented Dec 21, 2016

This pull request adds two important things

  • Ability to limit port pool for dynamic ports per nomad client. This helps to expose running services to public network using port forwarding when nomad cluster behind NAT. For example, if we can limit dynamic port pool for nomad client SRV1 to range [30000, 30999], for SRV2 to [31000, 31999] and then configure port forwarding rules to expose specific ports of nodes to public network.

  • Allocating several consequent ports (a range of ports) for a task, see Feature request: Allocating dynamic port range for task #1384 for more info.

This pool request is far from complete, it is more like proof of concept. Currently it can allocate tasks with dynamic port ranges and limiting port range also works correctly. I have to use more optimal algorithm for allocating port ranges and add some configuration options for adjusting port pools.

Prior that I would like to listen to feedback from hashicorp guys: what do you think about features and current approach. I can allocate as much time as required to have it done so please don't hesitate to ask changes.

@@ -92,6 +92,13 @@ func (f *NetworkFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
f.logger.Printf("[DEBUG] fingerprint.network: link speed could not be detected and no speed specified by user. Defaulting to %d", defaultNetworkSpeed)
}

const INDIVIDUAL_POOL = "Individual Ports Pool"
const RANGE_POOL = "Port Ranges Pool"
individualPortsPool := structs.PortRange{Label: INDIVIDUAL_POOL, Base: 20000, Span: 20000}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going to add client configuration options to make this adjustable.

const INDIVIDUAL_POOL = "Individual Ports Pool"
const RANGE_POOL = "Port Ranges Pool"
// PortRange
individualPortsPool := PortRange{Label: INDIVIDUAL_POOL, Base: 20000, Span: 40000}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set individualPortsPool to [20000, 60000] by default to be backward compatible with old clients

MBits int // Throughput
ReservedPorts []Port // Reserved ports
DynamicPorts []Port // Dynamically assigned ports
DynamicPortRanges []PortRange // Dynamically assigned port ranges
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to merge DynamicPortRanges and DynamicPorts and use PortRange everywhere instead of Port struct

@scalp42
Copy link
Contributor

scalp42 commented Sep 7, 2017

We use the port range on Mesos/Marathon, this would be a great addition 👍

@karstenjakobsen
Copy link

Hi guys. Whats status with this feature request?

@preetapan
Copy link
Contributor

@capone212 Sorry that we didn't get to this all this time, I am doing some PR/issue housekeeping and will be closing this PR because the code has changed significantly from under it. We are keeping #1384 open to consider implementing in a future release. Let's keep future design discussion in the GH issue instead of here.

@preetapan preetapan closed this Feb 23, 2019
@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 Feb 14, 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.

4 participants