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

NETOBSERV-226 Refactor query API and filters management #105

Merged

Conversation

jotak
Copy link
Member

@jotak jotak commented Mar 24, 2022

JIRA https://issues.redhat.com/browse/NETOBSERV-226

Backend change:

  • Backend http API: more explicit query params to not mix filters with non-filter params
  • "Match any" rewritten: now runs multiple subqueries in parallel, and aggregate the results. It's a better use of labels (indexes), so should be more performant, and also less complexity in LogQL queries
  • Refactoring the groups logic to handle a couple of missing cases, like with match all + (Src+Dst) common filters. Still a complex part (but complexity was moved from the query builder to pre-processing of filters)
  • More separation between CSV-export code/endpoint and flow-fetching code/endpoint
  • Fixed some mixed up uses of stringLabelFilter / regexLabelFilter (basically: always use regexLabelFilter when regex is involved)
  • Removed some regex feature within exact match (it seems a bit weird to me to me exact match and regex..., and also simplified code to remove ... but we can add it back if there's really some use cases)
  • Some utility stuff ...
  • More tests

Frontend change:

  • Dissociate Columns vs Filters (we must be able to add new filters without adding new columns)
  • Adapt to new backend API: filters are now passed as a unique query param
  • Code quality: avoid super large files, split in more react components, etc.
  • Moved backend logic of all/any matching to frontend. Defining some of the logic rightly in the filter definition themselves help simplifying the code (IMHO)

@openshift-ci
Copy link

openshift-ci bot commented Mar 24, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@jotak
Copy link
Member Author

jotak commented Mar 24, 2022

opening as draft, needs frontend update (wip) and some cleanup

return parsed
}

// groupFilters creates groups of filters for fetching strategy, that depends on the match all/any param
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not super fan of this groupFilters function, will try to simplify it

Comment on lines 139 to 152
// inputPath: "?filters=" + url.QueryEscape("SrcK8S_Namespace=\"start-namespace*\""),
// outputQueries: []string{
// `?query={app="netobserv-flowcollector",SrcK8S_Namespace=~"^start-namespace.*"}`,
// },
// }, {
// inputPath: "?filters=" + url.QueryEscape("SrcK8S_Namespace=\"*end-namespace\""),
// outputQueries: []string{
// `?query={app="netobserv-flowcollector",SrcK8S_Namespace=~".*end-namespace$"}`,
// },
// }, {
// inputPath: "?filters=" + url.QueryEscape("SrcK8S_Namespace=\"mid-n*e\""),
// outputQueries: []string{
// `?query={app="netobserv-flowcollector",SrcK8S_Namespace=~"^mid-n.*e$"}`,
// },
Copy link
Member Author

Choose a reason for hiding this comment

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

@jpinsonneau I'd like to get your opinion on that. At the moment, I've removed this mix of exact-matching/start-matching/end-matching, mostly because I don't really see the point of having these particular matches using the double-quotes (which, to me, really mean exact match). I guess if you need these start/end matches, you can use the partial match without the double-quotes, no? Or am I missing a use case?

Copy link
Contributor

Choose a reason for hiding this comment

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

sure so as soon as you will find a * char in the filter you will go for partial match right ?

@jotak jotak force-pushed the refactor-backend-flow-api branch from bd5c3e5 to eb71fcb Compare March 24, 2022 11:23
aggStreams = streams
aggregated = r
} else {
aggStreams = append(aggStreams, streams...)
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you plan to remove duplicates here ?
What about the limit ?

Copy link
Member Author

Choose a reason for hiding this comment

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

good points, it needs dedup, I will work on it.

for limit, either we just throw away results outside of the limit, but but it might be a shame, so another option could be to find some twist in the UI to not present the limit option as something hard-defined, but with a more qualitative wording instead? (e.g 100 => fetch few, 500 => fetch more , 1000 => fetch many more .. or find something better) any idea?

For sure this solution comes with some challenges, but IMO we cannot continue without using loki indexes if we want to scale

@jotak jotak force-pushed the refactor-backend-flow-api branch from eb71fcb to 8f8aba6 Compare March 24, 2022 17:38
@jotak jotak force-pushed the refactor-backend-flow-api branch from 2443a0a to bebd019 Compare March 30, 2022 10:31
@jotak jotak changed the title Refactor query API Refactor query API and filters management Mar 30, 2022
@jotak jotak requested a review from jpinsonneau March 30, 2022 12:44
@jotak jotak added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Mar 30, 2022
@jotak
Copy link
Member Author

jotak commented Mar 30, 2022

@jpinsonneau this is almost ready, I think it's fine to start reviewing / testing, though there's still a couple of things that I need to do:

  • Test / fix the CSV export (I'm pretty sure it's broken)
  • Restore some missing filters
  • Check use of _.cloneDeep(filters) (probably bugged)
  • Add some tests (e.g. on flow-query.ts)
  • Restore more tests on filters component

I've edited the PR description to add details about what changed / why.

@jotak jotak force-pushed the refactor-backend-flow-api branch from 44dc2d8 to 99551dd Compare March 30, 2022 12:54
@jotak jotak added ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. and removed ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. labels Mar 30, 2022
@github-actions
Copy link

New image: ["quay.io/netobserv/network-observability-console-plugin:9a460ce"]. It will expire after two weeks.

@jotak jotak force-pushed the refactor-backend-flow-api branch from a025f97 to 7b1265b Compare March 30, 2022 16:46
@jotak jotak added ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. and removed ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. labels Mar 31, 2022
@jotak jotak force-pushed the refactor-backend-flow-api branch from f267539 to 13e2c0f Compare March 31, 2022 16:03
@jotak jotak added ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. and removed ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. labels Mar 31, 2022
@github-actions
Copy link

New image: ["quay.io/netobserv/network-observability-console-plugin:2329388"]. It will expire after two weeks.

@jotak
Copy link
Member Author

jotak commented Mar 31, 2022

New image: ["quay.io/netobserv/network-observability-console-plugin:2329388"]. It will expire after two weeks.

@memodi hey, here's the image built from CI

@jotak jotak changed the title Refactor query API and filters management NETOBSERV-226 Refactor query API and filters management Apr 1, 2022
@jotak jotak requested a review from jpinsonneau April 6, 2022 07:20
jotak added 4 commits April 7, 2022 09:33
- Backend http API: more explicit query params to not mix filters with non-filter params
- "Match any" rewritten: now runs multiple subqueries in parallel, and aggregate the results. It's a better use of labels (indexes), so should be  more performant, and also less complexity in LogQL queries
- Refactoring the groups logic to handle a couple of missing cases, like with match all + (Src+Dst) common filters. Still a complex part (but complexity was moved from the query builder to pre-processing of filters)
- More separation between CSV-export code/endpoint and flow-fetching code/endpoint
- Fixed some mixed up uses of stringLabelFilter / regexLabelFilter (basically: always use regexLabelFilter when regex is involved)
- Removed some regex feature within exact match (it seems a bit weird to me to me exact match and regex..., and also simplified code to remove ... but we can add it back if there's really some use cases)
- Some utility stuff ...
- More tests

Add some test, move export handler to own file

Remove the filters grouping logic

It will be implemented straight from the frontend
- Dissociate Columns vs Filters (we must be able to add new filters
  without adding new columns)
- Adapt to new backend API: filters are now passed as a unique query
  param
- Code quality: avoid super large files, split in more react components,
  etc.
- Moved backend logic of all/any matching to frontend. Defining some of
  the logic rightly in the filter definition themselves help simplifying
the code

Fix case with different and-filter on same key

Fix k8s resource autocompletion, add tests

Also fix k8s name regex being too permissive

Fix CSV export

Add some missing filters

- Owner name
- Owner kind (merged with kind)
- Host renamed Node IP

Add more tests

fix conflicts

Fix warning in test

Warning about state modified outside of 'act' was triggered.
- LogQL fix on json "or" fields
- Close autocomplete popup on blur
- Avoid unnessary call to setIndicator
There was 2 problems with the algo:
- Flow records are {stream selector} * Entry line, that is, each
  entry line in the results has to be considered individually, and
merged for iodentical stream selectors
- Labels order in stream selector can vary. They must be compared in a
  consistent way
@jotak
Copy link
Member Author

jotak commented Apr 7, 2022

@jpinsonneau my last commit should fix the issue that we've seen

@jotak jotak force-pushed the refactor-backend-flow-api branch from ae47385 to d8ec2ed Compare April 7, 2022 09:11
@jotak jotak added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Apr 7, 2022
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

New image: ["quay.io/netobserv/network-observability-console-plugin:f4047c6"]. It will expire after two weeks.

@memodi
Copy link
Contributor

memodi commented Apr 7, 2022

/cc @brahaney

@openshift-ci openshift-ci bot requested a review from brahaney April 7, 2022 15:40
@memodi
Copy link
Contributor

memodi commented Apr 7, 2022

@jotak I tested this and didn't find any issues with it. Except for my this comment and UX discussion doc which can be probably addressed in follow up tasks if you agree, rest LGTM. I'll let @brahaney add qe-approved label based on his test results.

Copy link

@brahaney brahaney left a comment

Choose a reason for hiding this comment

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

/qe-approved

@jotak
Copy link
Member Author

jotak commented Apr 8, 2022

Thank you @brahaney @memodi @jpinsonneau !
Julien, I don't know if you resume your tests since Dan and Mehul approved, let me know if you find anything wrong

@jotak
Copy link
Member Author

jotak commented Apr 8, 2022

/approve

@openshift-ci
Copy link

openshift-ci bot commented Apr 8, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Apr 8, 2022
@openshift-merge-robot openshift-merge-robot merged commit eadc9be into netobserv:main Apr 8, 2022
@jpinsonneau
Copy link
Contributor

Here are some feedback about my today's tests:

  • I'm not able to type "* or *" for start / end match in Name filter in front end anymore
    export const k8sName = RegExp('^[-a-zA-Z0-9*]*$');
    image
    This works fine for Labels like Namespaces
  • Resource dropdown doesn't work with Node. value even if it's suggested in the list
    image

Not sure if it's related to this PR but I've also seen these bugs:

  • Wrong source / destination results
    • Set 'Destination Name' to 'loki'
    • Wrong "dns-default" match
      image
  • Wrong port results:
    • Set 'Port' to '80'
    • Getting results about '8080'
      image

jotak added a commit to jotak/network-observability-console-plugin that referenced this pull request Apr 8, 2022
Fixes netobserv#105 (comment)
wrong "dns-default" appearing when searching for dest name loki
jotak added a commit to jotak/network-observability-console-plugin that referenced this pull request Apr 8, 2022
Fixes netobserv#105 (comment)
wrong "dns-default" appearing when searching for dest name loki
@jotak
Copy link
Member Author

jotak commented Apr 8, 2022

@jpinsonneau I fixed 2 of the mentioned issues, and created 2 tickets for the others:

openshift-merge-robot pushed a commit that referenced this pull request Apr 19, 2022
Fixes #105 (comment)
wrong "dns-default" appearing when searching for dest name loki
@jotak jotak deleted the refactor-backend-flow-api branch November 7, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test To set manually when a PR is safe to test. Triggers image build on PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants