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

Allow services to use same port with different protocols #907

Merged
merged 1 commit into from
Mar 7, 2018
Merged

Allow services to use same port with different protocols #907

merged 1 commit into from
Mar 7, 2018

Conversation

caglar10ur
Copy link
Contributor

@caglar10ur caglar10ur commented Jan 7, 2018

kompose fails if compose file declares different protocols for the same port. eg;

...
     ports:
      - 666:666/udp
      - 666:666/tcp
...

This PR adds the port to the output and also makes sure that names are unique for each port/protocol pair. This is supported with LoadBalancer (kubernetes/kubernetes#2995
) so trying to use this config with LB panics

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 7, 2018
@cdrage
Copy link
Member

cdrage commented Jan 15, 2018

Hey @caglar10ur Seems that tests are failing.

Do you mind updating your PR with a description of what's happening here / being changed as well?

@caglar10ur
Copy link
Contributor Author

@cdrage sure thing. While at it I'll also add a fixture for this work.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 16, 2018
@caglar10ur
Copy link
Contributor Author

@cdrage done and now tests are passing too

Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

I still need to do another run-through when I have some time, but as of right now, other than some minor changes, this LGTM.

}
name = fmt.Sprintf("%s-%s", name, port.Protocol)
}
name = strings.ToLower(name)
Copy link
Member

Choose a reason for hiding this comment

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

I think that the output should be uppercase rather than lowercase. Only reason being is that UDP and TCP is by-default uppercase within Kubernetes. Would make more sense for the names to be: 80-UDP or 80-UDP by default.

if _, ok := seenPorts[int(port.HostPort)]; ok {
// https://github.com/kubernetes/kubernetes/issues/2995
if service.ServiceType == string(api.ServiceTypeLoadBalancer) {
panic("Services of type LoadBalancer cannot use both TCP and UDP for same port " + name)
Copy link
Member

Choose a reason for hiding this comment

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

This function should really be returning an err, but as of right now, that's in a future refactor.

Instead of a panic, can you please use log.Fatalf ? Would be helpful to output which service we're using too.

log.Fatalf("Service %s of type LoadBalancer cannot use TCP and UDP for the same port", name)

@caglar10ur
Copy link
Contributor Author

@cdrage pushed a new commit to address your comments. Thanks!

@cdrage
Copy link
Member

cdrage commented Jan 17, 2018

@caglar10ur Do you mind if you merge the two commits? Push with 1 commit? 👍

kompose fails if compose file declares different protocols for the same port. eg;

...
     ports:
      - 666:666/udp
      - 666:666/tcp
...

This PR adds the port to the output and also makes sure that names are unique for each port/protocol pair.
This is supported with LoadBalancer (kubernetes/kubernetes#2995) so trying to use this config with LB panics.
@caglar10ur
Copy link
Contributor Author

caglar10ur commented Jan 17, 2018

@cdrage squashed and pushed

@surajnarwade
Copy link
Contributor

@caglar10ur , semaphore CI is breaking :(

@caglar10ur
Copy link
Contributor Author

@surajnarwade not sure what is going on there as I didn't see anything alarming in the logs and assumed intermittent CI failure. Do you see an error that I'm not seeing or missing?

@cdrage
Copy link
Member

cdrage commented Mar 6, 2018

Sorry for that @caglar10ur, @surajnarwade is wrong.

Our OpenShift tests have been kind of flakey lately. Ignore that test. I'll re-run it anyways!

@cdrage
Copy link
Member

cdrage commented Mar 6, 2018

This LGTM, @surajnarwade mind doing a quick review and we can merge this in? 👍

@surajnarwade surajnarwade merged commit 908e3f1 into kubernetes:master Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants