-
Notifications
You must be signed in to change notification settings - Fork 669
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
Add support for AppProtocol as well as service annotations #4603
Conversation
Signed-off-by: Evan Anderson <evana@vmware.com>
411859f
to
ba66222
Compare
Codecov Report
@@ Coverage Diff @@
## main #4603 +/- ##
=======================================
Coverage 76.81% 76.81%
=======================================
Files 140 140
Lines 12993 12995 +2
=======================================
+ Hits 9980 9982 +2
Misses 2751 2751
Partials 262 262
|
I think we might want to add some validation here since the |
This seems to only be used here: Which only uses certain specific values, and ignores the rest. I suppose we might be able to save a little memory by not copying these strings around. |
(hit the wrong button again) |
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.
The idea looks good, but I'm unclear how the logic in upstreamProtocol
works. If it's just me, maybe a comment to explain it?
@@ -99,6 +99,9 @@ func upstreamProtocol(svc *v1.Service, port v1.ServicePort) string { | |||
if protocol == "" { | |||
protocol = up[strconv.Itoa(int(port.Port))] | |||
} | |||
if protocol == "" && port.AppProtocol != nil { |
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.
Shouldn't this check be before the previous one? Since the previous one will change the value of protocol if it's empty, and this one expects protocol to be empty, so it will never get hit?
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 kept the existing logic using the projectcontour.io/upstream-protocol.XXX
annotations as primary overrides.
If the port's Name
or Port
as a string isn't in the annotation map, protocol
will have the default string value (""
), and so the first part of the if
will be true.
I can add a comment if this default-ness of Go feels too subtle. (You can verify this works in the tests, though I should have added a case with both annotation and AppProtocol
to make the priority more clear.)
I preferred the existing annotation to avoid breaking users who had made specific changes to their services for Contour, on the assumption that they knew what they were doing.
Signed-off-by: Evan Anderson <evana@vmware.com>
8be2b80
to
bdf5d57
Compare
Signed-off-by: Evan Anderson <evana@vmware.com>
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 added a changelog entry, and clarified that AppProtocol
doesn't override the contour-specific Service annotation.
@@ -99,6 +99,9 @@ func upstreamProtocol(svc *v1.Service, port v1.ServicePort) string { | |||
if protocol == "" { | |||
protocol = up[strconv.Itoa(int(port.Port))] | |||
} | |||
if protocol == "" && port.AppProtocol != nil { |
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 kept the existing logic using the projectcontour.io/upstream-protocol.XXX
annotations as primary overrides.
If the port's Name
or Port
as a string isn't in the annotation map, protocol
will have the default string value (""
), and so the first part of the if
will be true.
I can add a comment if this default-ness of Go feels too subtle. (You can verify this works in the tests, though I should have added a case with both annotation and AppProtocol
to make the priority more clear.)
I preferred the existing annotation to avoid breaking users who had made specific changes to their services for Contour, on the assumption that they knew what they were doing.
(Let me know if I should continue with this, or try a different avenue) |
Marking this PR stale since there has been no activity for 14 days. It will be closed if there is no activity for another 30 days. |
We may want to reconsider whether we want to do this at all since this provision Gateway API GEP implies that |
Marking this PR stale since there has been no activity for 14 days. It will be closed if there is no activity for another 30 days. |
The Contour project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to the #contour channel in the Kubernetes Slack |
name: Pull request
about: Support using AppProtocol to detect backend protocol (pass-through current "tls", "h2", "h2c" values) in addition to projectcontour.io/upstream-protocol.X annotations
labels: ["release-note/small"]
Fixes #2431
Note that this does not do any particular validation of the AppProtocol field, but it does add tests. 😁