-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
port forward range test: fix an oops #14855
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM |
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
/hold
test/system/500-networking.bats
Outdated
local port="${range%-*}" | ||
local end_port="${range#-*}" |
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.
@Luap99 PTAL. The obvious question is, how did this ever work?
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.
It simply did not work. We just never looped in for port
.
But this is not even the actual problem I was reporting. The test picked 5354-5356
which is wrong, 5355 is always blocked. So the free port logic has a bug as well.
Testing this on my laptop, rootless, I'm reliably getting: $ bin/podman run --network bridge -p 5933-5955:5933-5955 -d quay.io/libpod/testimage:20220615 top
Error: failed to mount runtime directory for rootless netns: no such file or directory Looks like #13703, but this is f36, and it's not an SELinux issue (fails with |
That error can happen because of many different reasons. Try to cleanup the netns |
Thanks, that fixed it. I wonder if the error message could be fixed so it offers that command (rm -f ...) as a suggestion? That will be helpful to people who get that error message without having a clue what happened or how to fix it. Like me. |
Well there are downsides to this, for testing it is fine but in production you should not do it. The problem is that without the namespace newly started containers can not talk to containers started before you removed it. This whole thing is fragile and needs to be improved. Podman should be able to recover from this on its own without user intervention. |
@edsantiago I think we also need: diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 273e8d2f5..e4d44c4a9 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -300,7 +300,7 @@ function random_free_port_range() {
while [[ $maxtries -gt 0 ]]; do
local firstport=$(random_free_port)
local all_ports_free=1
- for i in $(seq 2 $size); do
+ for i in $(seq 1 $(($size - 1))); do
if ! port_is_free $((firstport + $i)); then
all_ports_free=
break right now it tests |
Yes, but there's also something else seriously broken. The whole |
Wrong variable. And, wrong index range. And, wrong bash syntax for extracting end_port. And, add explicit check for valid range, because die() inside 'foo=$(...)' will not actually die. And, refactor some confusing code. And, reformat/clean up a confusing and too-wide comment. Fixes: containers#14854 Signed-off-by: Ed Santiago <[email protected]>
cd16c6a
to
e8d2d70
Compare
This blew up. New changes are much, much more complicated than originally intended. However, the end result is IMO cleaner. |
@@ -677,16 +677,20 @@ EOF | |||
@test "podman run port forward range" { | |||
for netmode in bridge slirp4netns:port_handler=slirp4netns slirp4netns:port_handler=rootlesskit; do | |||
local range=$(random_free_port_range 3) | |||
local port="${test%-*}" | |||
local end_port="${test#-*}" |
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.
SUBTLE BUT IMPORTANT! Note the change of dash-asterisk to asterisk-star in this one!
/lgtm |
/hold cancel |
Wrong variable.
Fixes: #14854
Signed-off-by: Ed Santiago [email protected]