-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Generate a ssh port from 1025..9999 range #68
Conversation
It was possible to generate a ssh port <= 1024 before. This is ok for rootful containers but it doesn't work for rootless. That causes another re-provisioning attempt until the port above 1024 is generated. With this change the generated port is always within 1025..9999 inclusive range.
Codecov ReportBase: 84.05% // Head: 84.05% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #68 +/- ##
=======================================
Coverage 84.05% 84.05%
=======================================
Files 1 1
Lines 301 301
=======================================
Hits 253 253
Misses 48 48
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Having an explicit range is so much better than taking a substring on a random number. I do wonder if 9999 should be the max, or 65535.
Another thing I wonder about is whether Docker can't do this natively. So create the container and then inspect to find out whatever Docker assigned to it, but I guess we can leave that for another day.
This looks like a great idea. From a brief dig through the docker docs, if you want to use a specific port, you need to map it. I do like the idea of telling it that you want a mapping and letting it decide, but I don't think I've ever seen that done anywhere. We should probably improve this at some point to validate that the port we're trying to use isn't already in use but that may be done elsewhere, I don't quite recall. |
I thought about this but decided to keep the port to have 4 digits as before. Another idea was to make the range configurable (via env vars e.g.) |
Wrt inspecting the container it's quite possible:
N.B. |
Well.. I tried to remove the following lines: https://github.com/voxpupuli/beaker-docker/blob/master/lib/beaker/hypervisor/docker.rb#L80-L82
.. and
Relevant debug output from `rake beaker`
|
We'll need to give it a go from "real" docker as well. |
I'll try with |
It was possible to generate a ssh port <= 1024 before. This is ok for rootful containers but it doesn't work for rootless. That causes another re-provisioning attempt until the port above 1024 is generated. With this change the generated port is always within 1025..9999 inclusive range.