Skip to content
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

Kube Play - allow setting and overriding published host ports #16880

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

ygalblum
Copy link
Contributor

Does this PR introduce a user-facing change?

Yes

Kube Play - Add --publish flag to set or override port publishing

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Dec 18, 2022
@ygalblum
Copy link
Contributor Author

This PR is the first step in addressing #16595

@ygalblum ygalblum force-pushed the kube-publish-ports branch 3 times, most recently from 3e86976 to 42a00be Compare December 19, 2022 08:48
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@Luap99 @umohnani8 PTAL

test/e2e/play_kube_test.go Outdated Show resolved Hide resolved
cmd/podman/kube/play.go Show resolved Hide resolved
docs/source/markdown/podman-kube-play.1.md.in Outdated Show resolved Hide resolved
pkg/domain/infra/abi/play.go Outdated Show resolved Hide resolved
Comment on lines +4583 to +4909
// The error message is printed only on local call
if !IsRemote() {
Expect(kube.OutputToString()).Should(ContainSubstring("rootlessport cannot expose privileged port 80"))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bug and should be fixed? assuming this is already the case before this PR could you fill a issue for it

test/e2e/play_kube_test.go Outdated Show resolved Hide resolved
test/e2e/play_kube_test.go Outdated Show resolved Hide resolved
test/e2e/play_kube_test.go Show resolved Hide resolved
test/e2e/play_kube_test.go Outdated Show resolved Hide resolved
@ygalblum
Copy link
Contributor Author

I've fixed the code according to the comments. But, I think we need to align the functionality between the two changes this and #16766 before we proceed with either of them

@TomSweeneyRedHat
Copy link
Member

A number of red tests. The changes LGTM in general, I'll let others decide on the thumb-wrestling between this and #16766

@ygalblum ygalblum force-pushed the kube-publish-ports branch from 0b44907 to 48d9973 Compare January 1, 2023 07:49
@ygalblum
Copy link
Contributor Author

ygalblum commented Jan 3, 2023

@Luap99 I've fixed the code according to your comment. Please see my explanation here: #16880 (comment).
@dcermak wrote in #16766 that he thinks this PR should go in first. So, if you agree, let's continue here so he can complete his change as well

pkg/domain/infra/abi/play.go Outdated Show resolved Hide resolved
@ygalblum ygalblum force-pushed the kube-publish-ports branch from 48d9973 to a50b51c Compare January 4, 2023 16:35
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly looks good, the test should make sure both ports are present

kube := podmanTest.Podman([]string{"play", "kube", "--publish", "19007:80/udp", kubeYaml})
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(0))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs an inspect or something to make sure that both ports are defined, your test only check for the tcp port below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the test to test both UDP and TCP connections. So, I guess there's no need for inspect, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure that works too

kube := podmanTest.Podman([]string{"play", "kube", "--publish", "19010:19008/tcp", kubeYaml})
kube.WaitWithDefaultTimeout()
Expect(kube).Should(Exit(0))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the test to test both UDP and TCP connections. So, I guess there's no need for inspect, right?

for _, publishedPort := range publishedPorts {
if port.ContainerPort >= publishedPort.ContainerPort && port.ContainerPort < publishedPort.ContainerPort+publishedPort.Range && isSamePortProtocol(port.Protocol, publishedPort.Protocol) {
return true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

necessary newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fixed

@ygalblum ygalblum force-pushed the kube-publish-ports branch 2 times, most recently from 46676b2 to f8b0959 Compare January 5, 2023 07:57
@rhatdan
Copy link
Member

rhatdan commented Jan 5, 2023

/approve
@ygalblum Looks like your test is failing?

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 5, 2023
@ygalblum
Copy link
Contributor Author

ygalblum commented Jan 6, 2023

@containers/podman-maintainers The tests pass locally. Looking at the failure logs, it seems that the containers are started successfully, but then the test code fails to connect to the port. In addition, other flavors of the suite pass. So, it might be a difference in the setup that causes the failures. Can you think of a reason why they fail in the CI?

@Luap99
Copy link
Member

Luap99 commented Jan 6, 2023

CI systems are always much slower compared to local. You need to add some retry mechanism for the connect in the test. If we do a podman run -d or in this case podman play kube it will return as soon as the container process is started but that does not mean that this container process is ready to accept incoming connections.
something like this

// Wait for the nginx service to be running
for i := 0; i < 6; i++ {
// Test curl against the container's name
c1 := podmanTest.Podman([]string{"run", "--dns-search", "dns.podman", "--network=" + netName, NGINX_IMAGE, "curl", "web"})
c1.WaitWithDefaultTimeout()
worked = c1.ExitCode() == 0
if worked {
break
}
time.Sleep(interval)
interval *= 2
}
Expect(worked).To(BeTrue())

@rhatdan rhatdan added the 4.4 label Jan 7, 2023
@ygalblum ygalblum force-pushed the kube-publish-ports branch from f8b0959 to 16ff0bc Compare January 8, 2023 06:50
@ygalblum
Copy link
Contributor Author

ygalblum commented Jan 8, 2023

@Luap99 Thanks for the tip. I've updated the test code

@rhatdan
Copy link
Member

rhatdan commented Jan 8, 2023

Lint is not happy with this change.

Add a new flag --publish
Remote - Pass PublishPorts as a string array
ABI - translate the string array to Ports and merge with the ports in the spec
Add e2e tests
Add option to man doc

Signed-off-by: Ygal Blum <[email protected]>
@ygalblum ygalblum force-pushed the kube-publish-ports branch from 6596dcb to 07cc49e Compare January 8, 2023 11:49
@ygalblum
Copy link
Contributor Author

ygalblum commented Jan 8, 2023

Lint is not happy with this change.

Thanks, fixed

@ygalblum
Copy link
Contributor Author

ygalblum commented Jan 9, 2023

@containers/podman-maintainers can someone please restart the failed test. This time it is unrelated to my changes

@mheon
Copy link
Member

mheon commented Jan 9, 2023

Done

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rhatdan
Copy link
Member

rhatdan commented Jan 9, 2023

/lgtm
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 9, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 9, 2023
@ygalblum
Copy link
Contributor Author

@Luap99 I've made all the change and all tests are done and passing, but the PR still has the "Changes requested" state. Can you please re-review?

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, rhatdan, ygalblum

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Luap99
Copy link
Member

Luap99 commented Jan 10, 2023

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 10, 2023
@openshift-merge-robot openshift-merge-robot merged commit 6ba308f into containers:main Jan 10, 2023
@ygalblum ygalblum deleted the kube-publish-ports branch January 11, 2023 06:30
@baude
Copy link
Member

baude commented Feb 3, 2023

/cherry-pick v4.4

@openshift-cherrypick-robot
Copy link
Collaborator

@baude: #16880 failed to apply on top of branch "v4.4":

Applying: Kube Play - allow setting and overriding published host ports
Using index info to reconstruct a base tree...
M	cmd/podman/kube/play.go
M	docs/source/markdown/podman-kube-play.1.md.in
M	pkg/api/handlers/libpod/kube.go
M	pkg/bindings/kube/types.go
M	pkg/bindings/kube/types_play_options.go
M	pkg/domain/entities/play.go
M	pkg/domain/infra/abi/play.go
M	pkg/domain/infra/tunnel/kube.go
M	test/e2e/play_kube_test.go
Falling back to patching base and 3-way merge...
Auto-merging test/e2e/play_kube_test.go
CONFLICT (content): Merge conflict in test/e2e/play_kube_test.go
Auto-merging pkg/domain/infra/abi/play.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Kube Play - allow setting and overriding published host ports
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick v4.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vrothberg
Copy link
Member

This is already in the v4.4 branch

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants