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

Habitat should hunt for an available port if 9631 and 9638 are unavailable #3025

Closed
irvingpop opened this issue Aug 28, 2017 · 13 comments
Closed
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Stale Type:Additional Discussion Type: Feature Issues that describe a new desired feature

Comments

@irvingpop
Copy link

irvingpop commented Aug 28, 2017

As an operator of Habitized applications, I may want to use a networking mode like ECS Host-mode networking.

Since all ports are mapped to the host port, it means that my 2nd supervisor won't be able to successfully start - because ports 9631 and 9638 are already taken.

In these cases, it would be idea for the supervisor to automatically attempt to find an available port - hunting through an available range of ports. Chef-Zero used to have this same problem and was solved by chef/chef-zero#67

@reset reset added this to the Accepted Minor milestone Aug 28, 2017
@reset
Copy link
Collaborator

reset commented Aug 28, 2017

This may be a bit difficult to get done seeing we have an "initial peer" problem already, but it's something we should keep in mind as we attempt to solve for initial peer

@reset reset removed this from the Accepted Minor milestone Aug 28, 2017
@smith
Copy link
Contributor

smith commented Aug 28, 2017

The default behavior on Linux is to pick a random port if 0 is given to a program as a port number, so right now you can do hab sup run --listen-http 0.0.0.0:0 and it will run on a random port, but it won't tell you which port it's running on, you'll have to get that from lsof or netstat or something.

So, it's possible now but very user unfriendly; would be awesome if it was nice instead.

@irvingpop
Copy link
Author

that's a neat idea @smith ! unfortunately not usable for the gossip port, because it advertises itself to the census as having a gossip port and http port of 0:

          "sys": {
            "ip": "172.31.31.122",
            "hostname": "ip-172-31-31-122",
            "gossip_ip": "172.31.31.122",
            "gossip_port": 0,
            "http_gateway_ip": "0.0.0.0",
            "http_gateway_port": 0
          },

@irvingpop
Copy link
Author

agreed @reset - I've solved for the initial peer problem in my configuration, but you gotta gotta know which one is Habitat Prime and that one must be on the default port.

@irvingpop
Copy link
Author

Interesting, I may have actually pissed off all the supervisors in my ring by introducing that node listening on port 0:

ERROR:habitat_butterfly::server::outbound: Failed Ping to 172.31.31.122:0: Invalid argument (os error 22)
ERROR:habitat_butterfly::server::outbound: Failed Ping to 172.31.31.122:0: Invalid argument (os error 22)
Could not send rumor to "9fc4302dc0b14ea09dc1e4ba55e28d24" @ "172.31.31.122:0"; ZMQ said: Resource temporarily unavailable
Could not send rumor to "9fc4302dc0b14ea09dc1e4ba55e28d24" @ "172.31.31.122:0"; ZMQ said: Resource temporarily unavailable

@christophermaier
Copy link
Contributor

@irvingpop Makes sense... Rust's network code will pick a port for you if you specify 0, but Habitat's code isn't expecting you to do that, so it doesn't subsequently check to see what port was ultimately picked.

@eeyun eeyun changed the title RFE: Habitat should hunt for an available port if 9631 and 9638 are unavailable [RFC] Habitat should hunt for an available port if 9631 and 9638 are unavailable Nov 7, 2017
@rsertelon
Copy link
Contributor

I don't know if it should really be habitat's job to figure out which port to use. It seems more like an infrastructure constraint, and thus should be configured from outside habitat explicitly I think.

I figure that if you'd deploy two different containers with webservers in them, they might both use port 80, and it would be on the ops part to map/use something to configure another port for example, shouldn't it?

@bixu
Copy link
Contributor

bixu commented Nov 21, 2017

I feel a little bit uncomfortable about automating port selection by default. I would be much more comfortable having this turned on with a flag.

I'm reminded of this RFC I opened: #1939 - is the core problem we are trying to solve automatic bootstrapping of the initial ring?

@adamhjk
Copy link
Contributor

adamhjk commented Jan 24, 2018

I would be okay with it being a flag, but I'm not okay with it being on by default.

@eeyun eeyun changed the title [RFC] Habitat should hunt for an available port if 9631 and 9638 are unavailable Habitat should hunt for an available port if 9631 and 9638 are unavailable Feb 13, 2018
@eeyun
Copy link
Contributor

eeyun commented Feb 13, 2018

I think we're all in agreement that it would be a totally reasonable feature to have so long as it's implemented appropriately (e.g. behind some kind of toggle or flag). For now we're going to sort this into help wanted. If anyone with an interest in implementing this is ready to get started hacking feel free to reach out for some implementation guidance from the core team!

@stale
Copy link

stale bot commented Apr 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Apr 3, 2020
@christophermaier christophermaier added Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component and removed A-supervisor labels Jul 24, 2020
@stale stale bot removed the Stale label Jul 24, 2020
@christophermaier christophermaier added the Type: Feature Issues that describe a new desired feature label Jul 24, 2020
@stale
Copy link

stale bot commented Jul 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Jul 24, 2021
@stale
Copy link

stale bot commented Aug 29, 2021

This issue has been automatically closed after being stale for 400 days. We still value your input and contribution. Please re-open the issue if desired and leave a comment with details.

@stale stale bot closed this as completed Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Stale Type:Additional Discussion Type: Feature Issues that describe a new desired feature
Projects
None yet
Development

No branches or pull requests

9 participants