-
Notifications
You must be signed in to change notification settings - Fork 50
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
listen on 0.0.0.0 to detect port usage #300
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing 0.0.0.0 by 127.0.0.1 fixes the issue for me |
before there was no host in podman-desktop I'm wondering if it's like a windows vs mac problem |
Yes, either we could change the test depending on the platform, or another more conservative solution would be to check on all addresses (127.0.0.1 and 0.0.0.0) and consider the port free if it is in all of them, as we are not sure who is opening the port, and on which address (and the behaviour of systems seems to be different here: when the address is bound to 0.0.0.0, it can be either considered open or not open on 127.0.0.1) |
That maye podman machine dependant. On WSL when you ask port binding it uses 127.0.0.1 for the bound port. Let me try with an HyperV machine |
side question: should we add the port detection as part of Podman Desktop extension API ? |
Yes (I didn't dare ask ;) ) In the future, it would be helpful to complete the detection by checking the ports that could be used by stopped containers, so having this detection centralized would be nice |
I guess it really depends on the network used. Just made a test and by using network pasta it is also reachable at 127.0.0.1 on mac qemu. So I guess it really depends on the pod configuration. BTW i wonder why 0.0.0.0 is not working on Windows. Shouldn't it target everything? |
Seems node related as Java |
On my mac with qemu:
So gvproxy is listening on ANYADDR(*)
And it has set the REUSEADDR flag. So the behaviour is what is expected when trying to bind to localhost (resusable) or anyaddr (not reusable) from what I understand from:
It seems to me that trying to bind on ANYADDR would be the good approach, as it should cover all cases (REUSEADDR set or not, and socket bound to localhost or ANYADDR). I'm curious to know why it does not work on Windows |
Another solution, to get rid of these problems or reusability, would be to read the netstat data, for example https://www.npmjs.com/package/netstats |
Or try to connect to localhost:port ? |
This is what is currently done (before this PR), but this doesn't work on Mac, or more generally when the port is opened on ANYADDR with the flag REUSEADDR:
|
Moving to draft as this proposal does not work on Windows |
No you don't get me. Before it was trying to LISTEN on localhost:port. I'm proposing that in order to detect if the port is in use or not, we try to CONNECT to that port on localhost (or 0.0.0.0) |
ah, sorry, my bad :( Yes, but it seems it would be much more intrusive, as it will connect to the services, which could have potential side effects. I tried the node-netstat library (https://www.npmjs.com/package/node-netstat), but 1. it relies on the command I pushed a new commit to check on both addresses 127.0.0.1 and 0.0.0.0. IMO, it should cover all cases. Could you please make another test on Windows? |
72acc9a
to
a8198c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine for me on Win 11
@jeffmaury Is it working for you too on Windows? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on Windows and MacOS
…dels adding merlinite and granite models
What does this PR do?
Updates the function used to detect a free port, to try to listen on the address 0.0.0.0 instead of 127.0.0.1, as on Mac, a port opened on all addresses is detected as non open on 127.0.0.1
We had to fix the problem on odo lately, and we had chosen this solution:
What issues does this PR fix or reference?
Fixes #299
Fixes #297
How to test this PR?
See steps to reproduce in #299