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

Add support for AppProtocol as well as service annotations #4603

Closed

Conversation

evankanderson
Copy link


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. 😁

@evankanderson evankanderson requested a review from a team as a code owner June 29, 2022 08:17
@evankanderson evankanderson requested review from tsaarni and youngnick and removed request for a team June 29, 2022 08:17
Signed-off-by: Evan Anderson <evana@vmware.com>
@codecov
Copy link

codecov bot commented Jun 29, 2022

Codecov Report

Merging #4603 (3dd4269) into main (26aa541) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Impacted Files Coverage Δ
internal/dag/accessors.go 98.59% <100.00%> (+0.02%) ⬆️
internal/status/gatewaystatus.go 75.00% <0.00%> (ø)
internal/status/routeconditions.go 20.58% <0.00%> (ø)
internal/status/gatewayclassconditions.go 95.00% <0.00%> (ø)

@sunjayBhatia sunjayBhatia added the release-note/small A small change that needs one line of explanation in the release notes. label Jun 29, 2022
@sunjayBhatia
Copy link
Member

I think we might want to add some validation here since the AppProtocol field could be a wide range of values and we assume internally that protocol really only is one of tls h2 or h2c

@evankanderson
Copy link
Author

I think we might want to add some validation here since the AppProtocol field could be a wide range of values and we assume internally that protocol really only is one of tls h2 or h2c

This seems to only be used here:
https://github.com/projectcontour/contour/blob/main/internal/envoy/v3/cluster.go#L81

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.

@evankanderson
Copy link
Author

(hit the wrong button again)

Copy link
Member

@youngnick youngnick left a 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 {
Copy link
Member

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?

Copy link
Author

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>
Signed-off-by: Evan Anderson <evana@vmware.com>
Copy link
Author

@evankanderson evankanderson left a 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 {
Copy link
Author

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.

@evankanderson
Copy link
Author

(Let me know if I should continue with this, or try a different avenue)

@github-actions
Copy link

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.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 29, 2022
@sunjayBhatia
Copy link
Member

We may want to reconsider whether we want to do this at all since this provision Gateway API GEP implies that appProtocol is a pretty broad field that Gateway API does not intend to use to configure backend app details: kubernetes-sigs/gateway-api#1333 (https://github.com/kubernetes-sigs/gateway-api/pull/1333/files#diff-5ea234dff68be219d19428c1c6cee202f7df6a867a11d294bb16b0dff0c081aeR26-R30)

@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 18, 2022
@github-actions
Copy link

github-actions bot commented Sep 1, 2022

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.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 1, 2022
@github-actions
Copy link

github-actions bot commented Oct 1, 2022

The Contour project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 14d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, the PR is closed

You can:

  • Mark this PR as fresh by commenting or pushing a commit
  • Close this PR
  • Offer to help out with triage

Please send feedback to the #contour channel in the Kubernetes Slack

@github-actions github-actions bot closed this Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Service AppProtocol field
3 participants