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

Avoid relying on non-guaranteed proxy naming conventions #7

Open
banks opened this issue Mar 3, 2020 · 0 comments
Open

Avoid relying on non-guaranteed proxy naming conventions #7

banks opened this issue Mar 3, 2020 · 0 comments

Comments

@banks
Copy link

banks commented Mar 3, 2020

if strings.HasSuffix(s.Service, "sidecar-proxy") {
continue
}

This is a naming convention only and there is nothing in Consul stopping users from naming proxies differently if they don't use the sidecar_service helper.

The canonical way to tell if something is a Proxy in Connect's data model is if service.Kind == "connect-proxy". If it's important that it's specifically a sidecar proxy (not say an ingress loadbalancer) which is true in this case you need to also check for service.Proxy.DestinationServiceID != "" - The thing that canonically makes a Proxy service a sidecar is that field indicating that it is has exactly one app (destination) instance behind it.

So to correctly skip sidecar proxies in this loop the following should work:

  // Skip all sidecar proxy registrations
  if s.Service.Kind == api.ServiceKindConnectProxy && s.Service.Proxy.DestinationServiceID != "" {
      continue
    }

NOTE: In fact this whole loop might need to change making this issue moot. I'll explain more in the issue that I'll link below, but this was important to note to make sure the guarantees are understood here.

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

No branches or pull requests

2 participants