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

xds: generate endpoints directly from API gateway snapshot #17390

Merged
merged 14 commits into from
May 19, 2023

Conversation

sarahalsmiller
Copy link
Member

@sarahalsmiller sarahalsmiller commented May 17, 2023

Description

In order to move the gateway off of using an underlying ingress gateway, add functionality to generate API Gateway natively. Previously this code was all in a single branch, but for ease of tracking and reviewing, breaking this code into 4 separate PRs.

Testing & Reproduction steps

  • No user facing changes are present, current CI/CD process passing ensures no behavior changes.

Links

https://hermes.hashicorp.services/document/15kzB5wqhzzPOMWCD8SphpcYUAigUmJvV6R6y2MZUnJU

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

@sarahalsmiller sarahalsmiller added the backport/1.15 This release series is no longer active on CE. Use backport/ent/1.15. label May 17, 2023
@github-actions github-actions bot added the theme/envoy/xds Related to Envoy support label May 17, 2023
Copy link
Member

@nathancoleman nathancoleman left a comment

Choose a reason for hiding this comment

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

This LGTM, but I paired on it so would like an approval from someone else

agent/xds/resources_test.go Show resolved Hide resolved
sarahalsmiller and others added 2 commits May 17, 2023 16:19
Co-authored-by: John Maguire <john.maguire@hashicorp.com>
@nathancoleman nathancoleman requested a review from jm96441n May 18, 2023 16:39
Each listener would previously have all upstreams from any route that bound to the listener. This is problematic when a route bound to one listener also binds to other listeners and so includes upstreams for multiple listeners. The list for a given listener would then wind up including upstreams for other listeners.
@sarahalsmiller sarahalsmiller added pr/no-backport and removed backport/1.15 This release series is no longer active on CE. Use backport/ent/1.15. labels May 18, 2023
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
@sarahalsmiller
Copy link
Member Author

removing the backport label after talking with Nathan this morning

}

return nil
return h.recompileDiscoveryChains(snap)
Copy link
Member

@nathancoleman nathancoleman May 18, 2023

Choose a reason for hiding this comment

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

Previously, we would recompile the discovery chain every time xDS resources were generated, sort of a "pull" style trigger. Instead, this will recompile the discovery chains every time a related resource that we're watching changes, so more of a "push" style trigger.

// TODO Find a cleaner solution, can't currently pass unexported property types
var err error
cfgSnap.IngressGateway, err = cfgSnap.APIGateway.ToIngress(cfgSnap.Datacenter)
if err != nil {
return nil, err
}
return s.endpointsFromSnapshotIngressGateway(cfgSnap)
return s.endpointsFromSnapshotAPIGateway(cfgSnap)
Copy link
Member

Choose a reason for hiding this comment

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

This is the crux of the whole change that we're making: instead of converting to an ingress gateway snapshot and generating xDS resources from that, we generate xDS resources directly from our API gateway snapshot 🎉

@nathancoleman nathancoleman changed the title Net 3673 endpoints from snapshot api gateway xds: generate endpoints directly from API gateway snapshot May 18, 2023
Copy link
Contributor

@mikemorris mikemorris left a comment

Choose a reason for hiding this comment

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

Minor nits, overall LGTM! Explanatory comments were helpful in reviewing!


for i, service := range services {
id := NewUpstreamIDFromServiceName(structs.NewServiceName(service.Name, &service.EnterpriseMeta))
synthesizedChains[id] = compiled[i]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it guaranteed that the compiled discovery chains will always be in the same order as services? Cross-indexing like this without some validation like checking compiled.name == service.name feels a little sketchy.

Copy link
Member Author

Choose a reason for hiding this comment

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

For what its worth, I believe this was code was copied directly from the ToIngress function. I'll add a quick sanity check though since I'm not sure if its guaranteed.

agent/xds/endpoints.go Outdated Show resolved Hide resolved
agent/xds/endpoints.go Outdated Show resolved Hide resolved
agent/xds/endpoints.go Outdated Show resolved Hide resolved
@sarahalsmiller sarahalsmiller enabled auto-merge (squash) May 19, 2023 18:25
@sarahalsmiller sarahalsmiller merged commit 134aac7 into main May 19, 2023
@sarahalsmiller sarahalsmiller deleted the NET-3673-endpointsFromSnapshotAPIGateway branch May 19, 2023 18:51
nickethier pushed a commit that referenced this pull request May 26, 2023
* endpoints xds cluster configuration

* resources test fix

* fix reversion in resources_test

* Update agent/proxycfg/api_gateway.go

Co-authored-by: John Maguire <john.maguire@hashicorp.com>

* gofmt

* Modify getReadyUpstreams to filter upstreams by listener (#17410)

Each listener would previously have all upstreams from any route that bound to the listener. This is problematic when a route bound to one listener also binds to other listeners and so includes upstreams for multiple listeners. The list for a given listener would then wind up including upstreams for other listeners.

* Update agent/proxycfg/api_gateway.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* Restore import blocking

* Skip to next route if route has no upstreams

* cleanup

* change set from bool to empty struct

---------

Co-authored-by: John Maguire <john.maguire@hashicorp.com>
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-backport pr/no-changelog PR does not need a corresponding .changelog entry theme/envoy/xds Related to Envoy support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants