-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Publishing one randomized host port will lead to all host ports being randomized #8650
Comments
I'll take this. |
Confirmed, reproduces locally. |
We definitely want a backport of this one for RHEL, I think. |
Got it. Writing a test now to make sure we don't regress. |
@mheon wow! Does it work with port ranges as well? I thought I found a solution by removing the
|
Also filed #8651 which might be related. |
Fix in #8652 - you found part of the problem with |
The existing logic (Range > 0) always triggered, because range is guaranteed to be at least 1 (a single port has a range of 1, a two port range (e.g. 80-81) has a range of 2, and so on). As such this could cause ports that had a host port assigned to them by the user to randomly assign one instead. Fixes containers#8650 Fixes containers#8651 Signed-off-by: Matthew Heon <[email protected]>
Yes, #8652 fixes both issues. Thanks! |
The existing logic (Range > 0) always triggered, because range is guaranteed to be at least 1 (a single port has a range of 1, a two port range (e.g. 80-81) has a range of 2, and so on). As such this could cause ports that had a host port assigned to them by the user to randomly assign one instead. Fixes containers#8650 Fixes containers#8651 Signed-off-by: Matthew Heon <[email protected]>
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Using the
--publish
flag it is possible to either specify the host port explicitly or omit it. In the latter case the container runtime will allocate a random port. If multiple--publish
flags are used, and at least one of them omits the host port, then all host ports will be allocated randomly.Steps to reproduce the issue:
Describe the results you received:
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Not relevant (except if the bug isn't reproducible on less exotic systems).
Package info (e.g. output of
rpm -q podman
orapt list podman
):Installed from kubic
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
Physical machine.
Running with
--log-level debug
, the following relevant lines appear:Thus it looks like the command line parsing works correctly in parseSplitPort but fails somewhere between there an the subsequent specgen
If only explicit port mappings are specified (i.e., one '--publish 3000:3000` flag) then the loglines read:
No lines are logged from
specgen/generate/parsePortMapping
at all. So, maybe the problem is in the code block within if postAssignPort. When that branch is hit, then it looks like all host ports are being randomized.The text was updated successfully, but these errors were encountered: