vald icon indicating copy to clipboard operation
vald copied to clipboard

Allow passing query between egress filter and filter gateway.

Open kevindiu opened this issue 1 year ago • 9 comments

Description:

This PR updated the following changes:

  • Allow passing query to egress filter through FilterDistance and FilterVector API
    • See apis/proto/v1/filter/egress/egress_filter.proto
  • Update Search APIs to allow filter searching result using query
    • For the logic, see pkg/gateway/filter/handler/grpc/handler.go
  • Updated existing Insert, Update, Upsert, GetObject API to allow filter object before corresponding operation
    • Updated to allow passing different query through multiple filtering target
  • Add example code, including example egress filter implementation, and example client code to connect to filter gateway using query filter feature.
    • See example/client/gateway/filter/README.md
  • Update related document about above changes.

Related Issue:

Versions:

  • Go Version: 1.20.3
  • Docker Version: 23.0.5
  • Kubernetes Version: 1.27.1
  • NGT Version: 2.0.9

Checklist:

Special notes for your reviewer:

You can check the behavior after this modification by reading the example/client/gateway/filter/README.md .

You may also need to edit the below file to enable filter gateway and setting the image tag to validate the implementation.

vim example/helm/values.yaml

gateway:
  filter:
    enabled: true
    image:
      tag: pr-2097

Please do not merge this PR, unless the target merge branch is updated.

Summary by CodeRabbit

  • New Features

    • Added support for new filter payload types: DistanceRequest, DistanceResponse, Query, VectorRequest, and VectorResponse.
    • Introduced query fields in filter configurations for enhanced filtering capabilities.
    • Implemented new methods for filtering distances and vectors.
    • Enhanced search functionality to support multiple ingress and egress filters.
    • Added aggregation algorithm options in search configurations.
  • Documentation

    • Updated API documentation to reflect new filter payload types and query fields.
    • Enhanced user guides with new filter configuration options and examples, including details on ingress and egress filters.

kevindiu avatar Jun 29 '23 05:06 kevindiu

[CHATOPS:HELP] ChatOps commands.

  • :ok_woman: /approve - approve
  • :love_letter: /changelog - replace the PR body by changelog details
  • :bento: /format - format codes and add licenses
  • :white_check_mark: /gen-test - generate test codes
  • :label: /label - add labels
  • :rewind: /rebase - rebase main
  • :end: :two: :end: /label actions/e2e-deploy - run E2E deploy & integration test

vdaas-ci avatar Jun 29 '23 05:06 vdaas-ci

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 844c7cb
Status: ✅  Deploy successful!
Preview URL: https://94d2939f.vald.pages.dev
Branch Preview URL: https://feature-egress-gateway-add-e.vald.pages.dev

View logs

[WARNING:INTCFG] Changes in interal/config may require you to change Helm charts. Please check.

vdaas-ci avatar Jun 29 '23 05:06 vdaas-ci

Codecov Report

Attention: Patch coverage is 1.85185% with 636 lines in your changes missing coverage. Please review.

Project coverage is 18.58%. Comparing base (e6f7db4) to head (844c7cb).

Files Patch % Lines
pkg/gateway/filter/handler/grpc/handler.go 0.00% 463 Missing :warning:
example/server/egress-filter/main.go 0.00% 53 Missing :warning:
example/server/ingress-filter/main.go 0.00% 35 Missing :warning:
apis/grpc/v1/payload/payload.pb.json.go 0.00% 20 Missing :warning:
pkg/tools/benchmark/job/service/object.go 0.00% 19 Missing :warning:
internal/config/benchmark.go 0.00% 14 Missing :warning:
.../grpc/v1/filter/egress/egress_filter_vtproto.pb.go 0.00% 10 Missing :warning:
internal/client/v1/client/filter/egress/client.go 0.00% 10 Missing :warning:
pkg/gateway/filter/handler/grpc/option.go 0.00% 8 Missing :warning:
pkg/gateway/filter/usecase/vald.go 0.00% 4 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2097      +/-   ##
==========================================
- Coverage   18.92%   18.58%   -0.34%     
==========================================
  Files         565      567       +2     
  Lines       65221    66426    +1205     
==========================================
+ Hits        12342    12348       +6     
- Misses      52080    53280    +1200     
+ Partials      799      798       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 29 '23 06:06 codecov[bot]

Profile Report

typevald-agent-ngtvald-lb-gatewayvald-discoverervald-manager-index
cpu
heap
other images

vdaas-ci avatar Jul 11 '23 03:07 vdaas-ci

I force pushed twice to rebase the branch to main branch. The first force push 3415596 to 92a7f0e is only squash commits in this branch without any changes, to easier rebase the branch. The second force push 92a7f0e to 4e437a5 is the actual rebase command.

kevindiu avatar Sep 04 '23 08:09 kevindiu

@vankichi @ykadowak Thank you for your previous review 🙏 Sorry, I updated the license header and the approval disappeared.... There is no change to the logic.

hlts2 avatar Jan 09 '24 04:01 hlts2

Walkthrough

Walkthrough

The changes introduce new payload types and update existing ones to support distance and vector-related requests and responses within the filter functionality. This includes modifications to API documentation, protocol buffers, Swagger files, user guides, and example implementations. The updates enhance the flexibility and clarity of filter configurations, allowing for more complex and detailed filtering operations.

Changes

File(s) Change Summary
apis/docs/v1/docs.md Added new payload types for distance and vector requests/responses, and updated existing entities to include query fields.
apis/proto/v1/filter/egress/egress_filter.proto Updated RPC definitions to use new request and response types from the payload.v1.Filter namespace.
apis/swagger/v1/filter/egress/egress_filter.swagger.json, apis/swagger/v1/vald/filter... Renamed and restructured definitions related to distance, vector, query, and responses for clarity and consistency.
docs/user-guides/client-api-config.md Modified configuration messages in the gRPC API, including updates to Config message fields for filters and timestamps.
example/server/egress-filter/main.go Introduced an egress filter server handling filtering requests for vectors based on specified criteria.
example/client/gateway/filter/main.go Added functionality for interacting with a Vald cluster through gRPC calls, including inserting, searching, retrieving, and removing objects.
.github/workflows/dockers-ci-container-image.yml Added "versions/NGT_VERSION" to the list of paths triggering the workflow.
docs/api/filter-gateway.md Updated Filter service configuration to include a Query field and allow multiple filter configurations.
docs/api/insert.md, docs/api/object.md, docs/api/search.md, docs/api/update.md, ... Changed filters fields from singular Filter.Config to repeated arrays of Filter.Config, allowing multiple filter configurations.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant FilterService
    participant EgressServer

    Client->>FilterService: Send FilterDistanceRequest
    FilterService->>EgressServer: Forward DistanceRequest
    EgressServer->>FilterService: Return DistanceResponse
    FilterService->>Client: Send FilterDistanceResponse

    Client->>FilterService: Send FilterVectorRequest
    FilterService->>EgressServer: Forward VectorRequest
    EgressServer->>FilterService: Return VectorResponse
    FilterService->>Client: Send FilterVectorResponse
sequenceDiagram
    participant User
    participant ValdClient
    participant ValdCluster

    User->>ValdClient: Insert Object
    ValdClient->>ValdCluster: Send Insert Request
    ValdCluster->>ValdClient: Confirm Insertion
    ValdClient->>User: Acknowledge Insertion

    User->>ValdClient: Search Object
    ValdClient->>ValdCluster: Send Search Request
    ValdCluster->>ValdClient: Return Search Results
    ValdClient->>User: Provide Search Results

    User->>ValdClient: Retrieve Object
    ValdClient->>ValdCluster: Send Retrieve Request
    ValdCluster->>ValdClient: Return Object
    ValdClient->>User: Provide Object

    User->>ValdClient: Remove Object
    ValdClient->>ValdCluster: Send Remove Request
    ValdCluster->>ValdClient: Confirm Removal
    ValdClient->>User: Acknowledge Removal

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar May 13 '24 08:05 coderabbitai[bot]