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

Streaming filter tags + case insensitive lookups for Service Names #9703

Merged

Conversation

pierresouchay
Copy link
Contributor

@pierresouchay pierresouchay commented Feb 4, 2021

Fixes #9695
Fixes #9702

This is also testing the 2 cases at once since I modified the DNS test:

  • Will test both case insensitive and tags lookups

@vercel vercel bot temporarily deployed to Preview – consul February 4, 2021 09:57 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 4, 2021 09:57 Inactive
@hashicorp-ci
Copy link
Contributor

🤔 Double check that this PR does not require a changelog entry in the .changelog directory. Reference

@pierresouchay pierresouchay force-pushed the streaming_tags_and_case_insensitive branch from 047f0a6 to 7a024ed Compare February 4, 2021 10:01
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 4, 2021 10:01 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 4, 2021 10:01 Inactive
@dnephin dnephin added theme/streaming Related to Streaming connections between server and client type/bug Feature does not function as expected labels Feb 4, 2021
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! This looks great.

I think the fix for case insensitivity is exactly right. I'm going to have a closer look at the tests, and also see if we can use https://github.com/hashicorp/go-bexpr to implement the filtering. I need to look at how this relates to the filtering we do in the cache right now. Filtering in a separate place might be ok if the tag field are not part of the cache key.

I'll work on getting this merged early next week.

@pierresouchay
Copy link
Contributor Author

We already deployed this on our clusters: https://github.com/criteo-forks/consul/commits/1.9.3-criteo seems to work well for now

@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 8, 2021 16:54 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 8, 2021 16:54 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 8, 2021 17:16 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 8, 2021 17:16 Inactive
@pierresouchay
Copy link
Contributor Author

@dnephin Also added node-meta filtering (see #9730) as it caused issues on our infra :-)

@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 9, 2021 18:20 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 9, 2021 18:20 Inactive
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thanks! Looking good, couple minor things I noticed.

I attempted to use the bexpr filters here: e2475cc, but I ran into a problem with the ServiceTags filtering, because bexpr is not case insensitive. I'll see if there is a way to make that work tomorrow. Otherwise I think copying the existing code from the server as you have done here makes sense.

agent/rpcclient/health/health.go Outdated Show resolved Hide resolved
agent/rpcclient/health/health.go Outdated Show resolved Hide resolved
Send empty array [] instead of [""] in DNS requests when TagFilter is not set

Do not change case sensitivity of services anymore in `getServiceNodes()` since
cache keys are now case insensitive
@vercel vercel bot temporarily deployed to Preview – consul February 10, 2021 10:28 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 10, 2021 10:28 Inactive
@pierresouchay
Copy link
Contributor Author

@dnephin All done

So that all the client side filtering is in the same place. Previously
only the bexpr filter was in the cache-entry.

Also makes a small change to the filtering so that instead of rebuilding
slices of items, the filtering can return a bool to determine if the
event payload is saved or not.
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you!

I pushed one commit which moves the filtering to where we call the current req.Filter in the cache-type. With this change we keep all the filtering in the same place, and we can do fewer allocations since the values get filtered before we store them. I added some tests that I had written while experimenting with the expr option.

I'm going to ask someone to look over the changes I've made tomorrow, but I think this is ready to merge.

@vercel
Copy link

vercel bot commented Feb 12, 2021

Deployment failed with the following error:

Creating the Deployment Timed Out.

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 Pierre and Daniel!

I had one Q inline but I'm sure enough that it's not an issue I've approved as-is anyway.

}

func serviceHasTag(sn *structs.NodeService, tag string) bool {
for _, t := range sn.Tags {
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure the answer is no, but do we ever need to handle the backcompat case where sn.Tag is set? I think not since this would have come from Consul's state store and every CSN from a version recent enough to support streaming would only use the plural field right?

Copy link
Contributor

@dnephin dnephin Feb 26, 2021

Choose a reason for hiding this comment

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

@dnephin dnephin merged commit 5c8a631 into hashicorp:master Feb 26, 2021
@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/332802.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/streaming Related to Streaming connections between server and client type/bug Feature does not function as expected
Projects
None yet
4 participants