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

Update proxycfg state management and xDS generation for transparent proxy #9894

Merged
merged 14 commits into from
Mar 18, 2021

Conversation

freddygv
Copy link
Contributor

@freddygv freddygv commented Mar 17, 2021

This PR makes a few changes:

  • Adds a cache-type for watches to the new Internal.IntentionUpstreams endpoint
  • Updates proxycfg watches to account for transparent proxy mode. In this mode we now need to watch our upstream services with the IntentionUpstreams endpoint, and then fire off additional discovery chain watches for those.
  • Updates xDS generation so that in transparent proxy mode we have a single listener with filter chains that correspond to each upstream service. These filter chains match on the original destination address so that Envoy can know which logical cluster to route to.

@freddygv freddygv requested a review from a team March 17, 2021 19:42
@github-actions github-actions bot added the theme/envoy/xds Related to Envoy support label Mar 17, 2021
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 17, 2021 21:17 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 17, 2021 21:17 Inactive
}

if chain == nil || chain.IsDefault() {
// TODO(rb): make this do the old school stuff too
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What old stuff was this?

if u.CentrallyConfigured {
continue
}
snap.ConnectProxy.UpstreamConfig[u.Identifier()] = &u
Copy link
Member

Choose a reason for hiding this comment

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

Note you are taking the address of the loop variable here, not the spot in the slice.

Copy link
Member

Choose a reason for hiding this comment

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

I think now you're taking the address of a copy of the slice item.

I think the fix would be = &s.proxyCfg.Upstreams[i]

@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 17, 2021 21:33 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 17, 2021 21:33 Inactive
@@ -54,35 +58,225 @@ func (s *Server) listenersFromSnapshot(cInfo connectionInfo, cfgSnap *proxycfg.C

// listenersFromSnapshotConnectProxy returns the "listeners" for a connect proxy service
func (s *Server) listenersFromSnapshotConnectProxy(cInfo connectionInfo, cfgSnap *proxycfg.ConfigSnapshot) ([]proto.Message, error) {
// One listener for each upstream plus the public one
resources := make([]proto.Message, len(cfgSnap.Proxy.Upstreams)+1)
resources := make([]proto.Message, 1)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a better guesstimate that we can use here now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There isn't a great one. If in TProxy mode there might only be 2 listeners, since it relies on per-upstream filter chains rather than per-upstream listeners. Outside of TProxy mode it could be the size of the DiscoverChain map.

Not sure if it's worth doing having a variable starting capacity based on whether TProxy is on or not.

agent/xds/listeners.go Outdated Show resolved Hide resolved
agent/xds/listeners.go Outdated Show resolved Hide resolved
cfgSnap *proxycfg.ConfigSnapshot,
tlsContext *envoy_tls_v3.DownstreamTlsContext,
) (*envoy_listener_v3.FilterChain, error) {
// TODO (freddy) Make this actually legible
Copy link
Member

Choose a reason for hiding this comment

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

I feel like there's some work we could do during ConfigSnapshot construction to alleviate some of this pain down here in the xDS code.

@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 17, 2021 22:19 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 17, 2021 22:19 Inactive
agent/xds/listeners.go Outdated Show resolved Hide resolved

// Only create the outbound listener when there are upstreams and filter chains are present
if outboundListener != nil && hasChains {
// Filter chains are stable sorted to avoid draining if the list is provided out of order
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@rboyer rboyer left a comment

Choose a reason for hiding this comment

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

Left more comments, but LGTM for the alpha.

@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 17, 2021 22:42 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 17, 2021 22:42 Inactive
Base automatically changed from intention-topology-endpoint to master March 17, 2021 23:39
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 18, 2021 03:38 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 18, 2021 03:38 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 18, 2021 03:47 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 18, 2021 03:47 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 18, 2021 04:09 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 18, 2021 04:09 Inactive
@freddygv freddygv merged commit fc02bb7 into master Mar 18, 2021
@freddygv freddygv deleted the tproxy-xds-alpha branch March 18, 2021 04:29
@hashicorp-ci
Copy link
Contributor

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/339575.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/envoy/xds Related to Envoy support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants