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

Improve Connect with Prepared Queries #5291

Merged
merged 4 commits into from
Feb 4, 2019
Merged

Conversation

mkeeler
Copy link
Member

@mkeeler mkeeler commented Jan 29, 2019

Given a query like:

{
   "Name": "tagged-connect-query",
   "Service": {
      "Service": "foo",
      "Tags": ["tag"],
      "Connect": true
   }
}

And a Consul configuration like:

{
   "services": [
      "name": "foo",
      "port": 8080,
      "connect": { "sidecar_service": {} },
      "tags": ["tag"]
   ]
}

If you executed the query it would always turn up with 0 results. This was because the sidecar service was being created without any tags. You could instead make your config look like:

{
   "services": [
      "name": "foo",
      "port": 8080,
      "connect": { "sidecar_service": {
         "tags": ["tag"]
      } },
      "tags": ["tag"]
   ]
}

However that is a bit redundant for most cases. This PR ensures that the tags and service meta of the parent service get copied to the sidecar service. If there are any tags or service meta set in the sidecar service definition then this copying does not take place. After the changes, the query will now return the expected results.

A second change was made to prepared queries in this PR which is to allow filtering on ServiceMeta just like we allow for filtering on NodeMeta.

This only happens if no other tags/meta are given in the sidecars service definition
@mkeeler mkeeler requested a review from a team as a code owner January 29, 2019 19:23
@mkeeler mkeeler requested a review from a team January 29, 2019 19:24
@mkeeler mkeeler force-pushed the feature/sidecar-service-meta branch from 403e409 to 9d5f136 Compare January 29, 2019 19:33
website/source/api/query.html.md Outdated Show resolved Hide resolved
website/source/api/query.html.md Outdated Show resolved Hide resolved
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.

LGTM

@mkeeler mkeeler requested a review from banks January 29, 2019 20:28
@mkeeler mkeeler added this to the 1.4.3 milestone Jan 29, 2019
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for this @mkeeler

Only change is that we need to update the sidecar service docs to reflect this. Specifically https://www.consul.io/docs/connect/proxies/sidecar-service.html#sidecar-service-defaults but take a look at whether the examples above need updating to be consistent too.

Should be a minor change.

agent/consul/prepared_query_endpoint.go Show resolved Hide resolved
@mkeeler mkeeler merged commit acfd87c into master Feb 4, 2019
@mkeeler mkeeler deleted the feature/sidecar-service-meta branch February 4, 2019 14:36
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.

3 participants