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

feat: Reconcile BackendRefs on EnvoyProxy #3190

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

davidalger
Copy link
Contributor

What this PR does / why we need it:

This adds support for BackendRefs on EnvoyProxies to the reconciler so the same endpoint discovery used for HTTPRoute refs will be used rather than DNS based discovery using service FQDNs.

Signed-off-by: David Alger <davidmalger@gmail.com>
@davidalger davidalger requested a review from a team as a code owner April 15, 2024 02:00
@davidalger davidalger marked this pull request as draft April 15, 2024 02:00
Signed-off-by: David Alger <davidmalger@gmail.com>
@davidalger davidalger force-pushed the algerdev/feat-ep-backendref-reconcile branch from 2899491 to da8d2d3 Compare April 15, 2024 02:05
…'t be needed

Signed-off-by: David Alger <davidmalger@gmail.com>
Signed-off-by: David Alger <davidmalger@gmail.com>
Signed-off-by: David Alger <davidmalger@gmail.com>
…hat wont't be needed"

Signed-off-by: David Alger <davidmalger@gmail.com>
Signed-off-by: David Alger <davidmalger@gmail.com>
@davidalger davidalger force-pushed the algerdev/feat-ep-backendref-reconcile branch from 76a4700 to 8491367 Compare April 16, 2024 20:04
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 61.76471% with 91 lines in your changes are missing coverage. Please review.

Project coverage is 66.65%. Comparing base (29946b0) to head (8491367).
Report is 128 commits behind head on main.

❗ Current head 8491367 differs from pull request most recent head e6040b2. Consider uploading reports for the commit e6040b2 to get more accurate results

Files Patch % Lines
internal/provider/kubernetes/controller.go 25.86% 37 Missing and 6 partials ⚠️
internal/provider/kubernetes/indexers.go 17.94% 30 Missing and 2 partials ⚠️
internal/gatewayapi/listener.go 89.41% 7 Missing and 2 partials ⚠️
internal/provider/kubernetes/predicates.go 72.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3190      +/-   ##
==========================================
+ Coverage   66.51%   66.65%   +0.14%     
==========================================
  Files         161      162       +1     
  Lines       22673    22962     +289     
==========================================
+ Hits        15080    15306     +226     
- Misses       6720     6781      +61     
- Partials      873      875       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidalger
Copy link
Contributor Author

/retest

Comment on lines +326 to +329
// TODO (davidalger) Handle case where Service referenced by backendRef doesn't exist
serviceNamespace := NamespaceDerefOr(backendRef.Namespace, envoyproxy.Namespace)
service := resources.GetService(serviceNamespace, string(backendRef.Name))
for _, port := range service.Spec.Ports {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will panic if the backendRef refers to a Service which cannot be found. Ideally this would surface as a message on the status somewhere, similar to how it does on XRoutes.

Status isn't currently being used on EnvoyProxy as far as I can tell. It seems it could make sense to put errors such as this on the Gateway rather than the EnvoyProxy since it's something which will arise when processing the Gateway.

@arkodg @zirain Do either of you have thoughts on where errors such as this should be surfaced?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah

  1. any EnvoyProxy errors are surfaced in the GatewayClass , lets tackle this separately, and raise a issue to track this because moving it to Accepted=False will break everything in the next reconciliation :)
  2. For now lets stick a Direct Response that returns 500 similar to
    ruleRoute.DirectResponse = &ir.DirectResponse{

@@ -141,6 +141,7 @@ func GetRenderedBootstrapConfig(opts *RenderBootsrapConfigOptions) (string, erro
StatsMatcher StatsMatcherParameters
)

// TODO (davidalger) push these through XDS?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zirain @arkodg Reconciling BackendRefs on EnvoyProxy for OTel Tracing and Access Logs is working, although there is a little more work to do to polish things up. OTel metrics is outstanding and I wanted to get thoughts on it before proceeding.

Since stats_sinks is used to configure metrics statically in the bootstrap, reconciling the clusters and feeding endpoint IPs in via XDS is probably not ideal as it would prevent metrics from being captured in the event Envoy fails to fetch XDS config at startup. My thinking is it may be ideal to keep this one as-is, preferring the current DNS discovery using an FQDN derived from the backendRef. If we agree on this, I'll remove reconciling backendRefs for metrics and leave this one as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

@zirain is there a way to dynamically setup metrics cluster via xds ?

# Conflicts:
#	internal/gatewayapi/listener.go
#	internal/gatewayapi/listener_test.go
#	internal/xds/translator/accesslog.go
#	internal/xds/translator/tracing.go
Signed-off-by: David Alger <davidmalger@gmail.com>
@arkodg
Copy link
Contributor

arkodg commented May 23, 2024

hey @davidalger @zirain, just realized that there's a massive overlap with this PR and #3293 , is this anything from this PR that is still required ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants