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
Default missing hostPort to containerPort is defined in kube.yaml #15946
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan 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 |
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.
I ran your new test against main @ aaeabb0. It passes (local & remote, root & rootless). That suggests that your test is not testing what you think it's testing. (Or, I'm missing something crucial, which is always a high probability).
test/system/700-play.bats
Outdated
|
||
@test "podman kube play - hostport" { | ||
HOST_PORT=$(random_free_port) | ||
TESTDIR=$PODMAN_TMPDIR/testdir |
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.
$PODMAN_TMPDIR
is fresh and new for each @test
; so I don't think you need $TESTDIR
.
LGTM; nice and easy |
test/system/700-play.bats
Outdated
|
||
run_podman kube play $PODMAN_TMPDIR/testpod.yaml | ||
run_podman pod inspect test_pod --format "{{.InfraConfig.PortBindings}}" | ||
is "$output" "map[$HOST_PORT/tcp:[{ $HOST_PORT}]]" |
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.
Whew! Figured out why test passes on main
. It's because the is
function tries an equal-match (==) first, but then tries expr
if that fails. Which means all those brackets end up meaning "map, plus maybe other stuff". Fix:
- is "$output" "map[$HOST_PORT/tcp:[{ $HOST_PORT}]]"
+ assert "$output" = "map[$HOST_PORT/tcp:[{ $HOST_PORT}]]"
asserts
, with explicit =
, will not try a regex match. With this fix, the test fails on main and passes with your PR.
LGTM |
/hold |
int tests are barking |
rootless is failing, and I'm kind of almost sure that it's this: podman/test/e2e/play_kube_test.go Line 137 in 5fc6d95
skip if rootless , maybe change the port, maybe remove that port line entirely.
|
Friendly suggestion: diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 67c88953a..651cb1074 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -133,8 +133,6 @@ spec:
containers:
- name: podnameEqualsContainerNameYaml
image: quay.io/libpod/alpine:latest
- ports:
- - containerPort: 80
`
var podWithoutAName = `
@@ -239,8 +237,6 @@ spec:
- "1.5"
name: alpine
image: quay.io/libpod/alpine:latest
- ports:
- - containerPort: 80
livenessProbe:
exec:
command:
@@ -274,8 +270,6 @@ spec:
- "1.5"
name: alpine
image: quay.io/libpod/alpine:latest
- ports:
- - containerPort: 80
livenessProbe:
exec:
command: Important note: I choose to remove the port lines completely, vs change to |
If user does not specify hostPort in a kube.yml file but does specify a containerPort, then the hostPort should default to the containerPort. Fixes: containers#15942 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
/lgtm |
/hold cancel |
podman play kube started to expose the port of containers in k8s deployments on the same port on the host with containers#15946. However, that breaks once replicas are involved, as they would then bind to the same port on the host. With this commit, we change the default behavior so that podman will pick a random port for the container instead of using `containerPort`, but only if no `hostPort` is set. This fixes: containers#16765 Signed-off-by: Dan Čermák <dcermak@suse.com>
podman play kube started to expose the port of containers in k8s deployments on the same port on the host with containers#15946. However, that breaks once replicas are involved, as they would then bind to the same port on the host. With this commit, we change the default behavior so that podman will pick a random port for the container instead of using `containerPort`, but only if no `hostPort` is set. This fixes: containers#16765 Signed-off-by: Dan Čermák <dcermak@suse.com>
podman play kube started to expose the port of containers in k8s deployments on the same port on the host with containers#15946. However, that breaks once replicas are involved, as they would then bind to the same port on the host. With this commit, we change the default behavior so that podman will pick a random port for the container instead of using `containerPort`, but only if no `hostPort` is set. This fixes: containers#16765 Signed-off-by: Dan Čermák <dcermak@suse.com>
podman play kube started to expose the port of containers in k8s deployments on the same port on the host with containers#15946. However, that breaks once replicas are involved, as they would then bind to the same port on the host. With this commit, we change the default behavior so that podman will pick a random port for the container instead of using `containerPort`, but only if no `hostPort` is set. This fixes: containers#16765 Signed-off-by: Dan Čermák <dcermak@suse.com>
podman play kube started to expose the port of containers in k8s deployments on the same port on the host with containers#15946. However, that breaks once replicas are involved, as they would then bind to the same port on the host. With this commit, we change the default behavior so that podman will pick a random port for the container instead of using `containerPort`, but only if no `hostPort` is set. This fixes: containers#16765 Signed-off-by: Dan Čermák <dcermak@suse.com>
podman play kube started to expose the port of containers in k8s deployments on the same port on the host with containers#15946. However, that breaks once replicas are involved, as they would then bind to the same port on the host. With this commit, we change the default behavior so that podman will pick a random port for the container instead of using `containerPort`, but only if no `hostPort` is set. This fixes: containers#16765 Signed-off-by: Dan Čermák <dcermak@suse.com>
If user does not specify hostPort in a kube.yml file but does specify a containerPort, then the hostPort should default to the containerPort.
Fixes: #15942
Signed-off-by: Daniel J Walsh dwalsh@redhat.com
Does this PR introduce a user-facing change?