-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
NET-4135 - Fix NodeMeta filtering Catalog List Services API #18322
Conversation
@david-yu - please help me with the backports. |
agent/consul/state/catalog.go
Outdated
parsedResult, err := parseServiceNodes(tx, ws, result, entMeta, peerName) | ||
if err != nil { | ||
return 0, nil, fmt.Errorf("failed querying and parsing services :%s", err) | ||
} | ||
return idx, parsedResult, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rboyer I saw you were the one that added parseServiceNodes
to a bunch of other endpoints back in 2022. Is there any performance implications we need to think about for adding this to this endpoint as well? This change is needed to fill in nodemeta so it can be filtered on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we only do the expensive join against the nodes
table when the user provides the NodeMeta parameter on the original API query. When they do this we call a completely different function link.
If we were concerned like that, we could instead alter the Store.Services
method to take an extra boolean parameter to conditionally join the NodeMeta as in this PR.
Then the calling code in agent/consul/catalog_endpoint.go
could set the flag to true
when filter != ""
OR just when:
strings.Contains(strings.ToLower(filter), "nodemeta")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rboyer I have updated the PR can I merge this now? please approve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rboyer I have updated the PR can I merge this now? please approve.
Can we simplify this consul/agent/consul/catalog_endpoint.go Lines 596 to 600 in 7f4fd27
|
I think we want to node-meta also. What do you think? |
I was wondering if NodeMetaFilters can be encoded as a bexpr expression. |
I think no, because node-meta is a json like structure but filter takes expression with == , "and" or "or" |
Added backports to 1.16.x, 1.15.x, and 1.14.x. |
Thank you for the review. @absolutelightning could you go ahead and merge and follow up with the backports? |
* logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
* logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
* logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
…PI into release/1.16.x (#19113) * backport of commit cef8e3d * NET-4135 - Fix NodeMeta filtering Catalog List Services API (#18322) * logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]> * removed unwanted log lines * removed unwanted log lines --------- Co-authored-by: absolutelightning <[email protected]> Co-authored-by: Ashesh Vidyut <[email protected]> Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
* logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
* logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
#18322) (#19115) NET-4135 - Fix NodeMeta filtering Catalog List Services API (#18322) * logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
…18322) (#19116) NET-4135 - Fix NodeMeta filtering Catalog List Services API (#18322) * logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
FYI this PR broke the enterprise tests. |
* logs for debugging * Init * white spaces fix * added change log * Fix tests * fix typo * using queryoptionfilter to populate args.filter * tests * fix test * fix tests * fix tests * fix tests * fix tests * fix variable name * fix tests * fix tests * fix tests * Update .changelog/18322.txt Co-authored-by: Ganesh S <[email protected]> * fix change log * address nits * removed unused line * doing join only when filter has nodemeta * fix tests * fix tests * Update agent/consul/catalog_endpoint.go Co-authored-by: R.B. Boyer <[email protected]> * fix tests * removed unwanted code --------- Co-authored-by: Ganesh S <[email protected]> Co-authored-by: R.B. Boyer <[email protected]>
Description
Fixed the working of filter query parameter in
/v1/catalog/services
API. Fixes - #17422Testing & Reproduction steps
Followed this tutorial and setup workloads in K8s.
Did curl -
PR Checklist