-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Differentiate UDP and TCP Protocols in Services #12628
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
Differentiate UDP and TCP Protocols in Services #12628
Conversation
Added |
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, except for some minor indentation issues and tests.
Maybe a painless way to test this in e2e tests is to simply change test/k8sT/manifests/demo_ds.yaml
to switch one of the services to use same ports for TCP and UDP. These services are then used in test/k8sT/Services.go
tests for NodePort, ExternalIP, externalTrafficPolicy=Local
, etc.
pkg/service/service.go
Outdated
@@ -603,7 +603,7 @@ func (s *Service) upsertServiceIntoLBMaps(svc *svcInfo, onlyLocalBackends bool, | |||
|
|||
err := s.lbmap.UpsertService( | |||
uint16(svc.frontend.ID), svc.frontend.L3n4Addr.IP, | |||
svc.frontend.L3n4Addr.L4Addr.Port, | |||
svc.frontend.L3n4Addr.L4Addr.Port, string(svc.frontend.L3n4Addr.L4Addr.Protocol), |
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.
There are some unit tests for this in service_test.go
. I think they could be extended to add a new frontend with just the protocol changed.
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.
These look to be unit tests and the lbmap service is just the mock service, so I don't know how much that will really tell us. Is there something else that you're referencing?
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.
Ah, no you're right.
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'd still add a unit test to check whether a svc doesn't get overwritten in pkg/service/service.go internal state if the same svc but with different proto gets added.
Thinking loud about the upgrade:
From the first glance it looks that no existing flow will be interrupted, as 1) |
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.
pkg/loadbalancer/loadbalancer.go:L3n4Addr.Hash()
should not omit the protocol.- I'd add some unit tests to
pkg/service
, also integration tests tok8sT/Services.go
. - Extend
migrate-svc
ink8sT/Updates.go
to test the upgrade.
b755786
to
f0b067e
Compare
c954fa9
to
db791c9
Compare
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 overall as a first-pass, just a minor item to address
d7d88cc
to
359f001
Compare
We have full kernel/e2e and runtime passes for this PR. The last commit, I think, doesn't need a full set of tests, as it is a simple matter of deleting a few lines of logging, and adding some integration tests. Assuming @brb is cool with putting off sockops protocol |
ran into #13262 |
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've given a detailed review to all files except the ones in test/
func FromNumber(proto uint8) (U8proto, error) { | ||
_, ok := protoNames[U8proto(proto)] | ||
if !ok { | ||
return 0, fmt.Errorf("unknown protocol %d", proto) |
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.
nit, any reason why the error on line 66 is quoted but this one is not?
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.
No, but since the primitive causing the error, in this case, isn't a string I think we should leave it as is.
@@ -22,7 +22,7 @@ import ( | |||
|
|||
k8sConst "github.com/cilium/cilium/pkg/k8s/apis/cilium.io" | |||
"github.com/cilium/cilium/pkg/versioncheck" | |||
"github.com/cilium/cilium/test/ginkgo-ext" | |||
ginkgoext "github.com/cilium/cilium/test/ginkgo-ext" |
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.
irrelevant change
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.
Go fmt goimports does this for me automatically (running go 1.15).
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.
Docs, policy changes were trivial. I'll give approval for these two codeowners. CLI and BPF seemed to already be reviewed by others so I didn't look too closely, looks like others already have comments, some of which still need to be addressed.
6e94a6e
to
b33559a
Compare
Saving protocol information in the lb(x)_key in bpf, as well as adding protocol information to service maps creation in the lbmap package ensures that translation, receiving, and forwarding will always take the protocol into proper account. Refactor cilium to always assume a protocol with a service. Refactor tests to account for service protocols. Update Documentation for kubeproxy-free nodeport example Since the output of `cilium service list` has changed the documentation should reflect the change. Fixes: #9207 Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
b33559a
to
cfdb026
Compare
test-me-please |
All green CI, as discussed out-of-band on Slack, feedback was addressed and recently requested changes on this PR have been largely cosmetic. Reviewers, if you still see anything worth following up on then please post those reviews and let @nathanjsweet know. |
Does this actually fix #9207? Last time I checked, it's still impossible for a pod to publish both a TCP and UDP as a service (such as 53) with the same port number. |
@briantopping No, this PR was later reverted because of an upgrade issue: #13587. This is now tracked at #9207, as you've seen. |
Yeah, that's just the GitHub UI being a bit broken: it doesn't understand when you reopen an issue that should have been fixed by a PR. |
Saving protocol information in the lb(x)_key in bpf, as well as
adding protocol information to service maps creation in the
lbmap package ensures that translation, receiving, and forwarding
will always take the protocol into proper account.
Signed-off-by: Nathan Sweet nathanjsweet@pm.me
Fixes: #9207