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

Refactor index manager service #2505

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kpango
Copy link
Collaborator

@kpango kpango commented May 21, 2024

Description

Related Issue

Versions

  • Go Version: 1.22.3
  • Rust Version: 1.77.2
  • Docker Version: 20.10.8
  • Kubernetes Version: v1.30.0
  • NGT Version: 2.2.1

Checklist

Special notes for your reviewer

Summary by CodeRabbit

  • New Features

    • Introduced a new endpoint /index/detail to retrieve index information for agents.
    • Added new sections in documentation to represent index counts and related information for each agent.
  • Bug Fixes

    • Updated the URL for downloading the HDF5 library tarball in the Dockerfile.
  • Refactor

    • Reorganized and updated various Go package imports for improved observability and tracing.
    • Reordered logic within the NewX509CertPool function for better handling of certificate pools and error conditions.
  • Dependencies

    • Upgraded multiple dependencies in go.mod, including Kubernetes-related packages and other libraries.
  • Documentation

    • Added detailed information on new structures and methods for handling index information for agents in the documentation.

deepsource-autofix bot added a commit that referenced this pull request May 21, 2024
This commit fixes the style issues introduced in 03b14b3 according to the output
from Gofumpt and Prettier.

Details: #2505
Copy link

cloudflare-pages bot commented May 21, 2024

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 073c643
Status: ✅  Deploy successful!
Preview URL: https://08bf88e6.vald.pages.dev
Branch Preview URL: https://refactor-manager-index-small.vald.pages.dev

View logs

Copy link
Contributor

coderabbitai bot commented May 21, 2024

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

191 files out of 248 files are above the max files limit of 50. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The recent changes encompass a variety of updates across multiple files, focusing on dependency upgrades, enhancements to Docker build caching, improvements to Go package management, and modifications to observability and tracing mechanisms. Key updates include upgrading GitHub release actions, adding new RPC methods for index details, updating Go module dependencies, and refining internal structures for better performance and observability.

Changes

File(s) Change Summary
.github/workflows/release.yml Upgraded GitHub release action from version 1 to version 2.
Makefile.d/dependencies.mk Added update/go to go/deps target for updating Go package dependencies.
Makefile.d/docker.mk Added cache configuration options for Docker build optimization.
Makefile.d/functions.mk Modified update-github-actions function to remove specific version setting for softprops/action-gh-release.
apis/docs/v1/docs.md, apis/proto/v1/manager/index/index_manager.proto, apis/proto/v1/payload/payload.proto, apis/swagger/v1/manager/index/index_manager.swagger.json Added new method IndexDetail and related structures for index information per agent.
dockers/tools/benchmark/job/Dockerfile Updated URL for downloading HDF5 library tarball.
example/client/go.mod, hack/go.mod.default Upgraded various dependencies, including Kubernetes-related packages and other libraries.
internal/info/info.go Reorganized Detail struct fields, added new fields, and updated initialization and handling logic.
internal/net/grpc/errdetails/errdetails.go Refactored DebugInfoFromInfoDetail function for better error handling and debugging information.
internal/net/http/metrics/pprof.go Added new routes for delta heap, mutex, and block profiles using pyprof.
internal/observability/trace/status.go, pkg/agent/core/faiss/handler/grpc/*.go, pkg/agent/core/ngt/handler/grpc/*.go Updated import paths for observability attributes.
internal/tls/tls.go Reordered logic in NewX509CertPool function to call x509.SystemCertPool() earlier.
pkg/agent/core/ngt/service/ngt_test.go Replaced grpc.DialOption with grpc.Client in test setup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHubActions
    participant Docker
    participant GoModules
    participant IndexService

    User->>GitHubActions: Trigger Release
    GitHubActions->>Docker: Build with Cache
    Docker->>GoModules: Install Dependencies
    User->>IndexService: Request Index Detail
    IndexService->>User: Return Index Information
Loading

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.

@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

apis/docs/v1/docs.md Show resolved Hide resolved
apis/docs/v1/docs.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 21, 2024

Codecov Report

Attention: Patch coverage is 21.12527% with 743 lines in your changes missing coverage. Please review.

Project coverage is 20.59%. Comparing base (f3fbbc2) to head (073c643).
Report is 1 commits behind head on main.

Files Patch % Lines
apis/grpc/v1/payload/payload_vtproto.pb.go 0.00% 316 Missing ⚠️
apis/grpc/v1/payload/payload.pb.go 4.76% 140 Missing ⚠️
internal/net/grpc/errdetails/errdetails.go 0.00% 23 Missing ⚠️
internal/net/grpc/status/status.go 19.04% 17 Missing ⚠️
internal/net/grpc/client.go 0.00% 15 Missing ⚠️
apis/grpc/v1/rpc/errdetails/error_details.pb.go 0.00% 14 Missing ⚠️
apis/grpc/v1/discoverer/discoverer_vtproto.pb.go 0.00% 12 Missing ⚠️
apis/grpc/v1/agent/core/agent_vtproto.pb.go 0.00% 11 Missing ⚠️
internal/client/v1/client/filter/ingress/client.go 0.00% 11 Missing ⚠️
internal/client/v1/client/filter/egress/client.go 0.00% 10 Missing ⚠️
... and 73 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2505      +/-   ##
==========================================
+ Coverage   18.95%   20.59%   +1.63%     
==========================================
  Files         565      419     -146     
  Lines       65225    43564   -21661     
==========================================
- Hits        12364     8972    -3392     
+ Misses      52061    34181   -17880     
+ Partials      800      411     -389     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Outside diff range and nitpick comments (2)
apis/proto/v1/payload/payload.proto (1)

526-534: Add documentation for the new fields in the Detail message to enhance clarity.

apis/docs/v1/docs.md (1)

26-27: Add a brief description for the new section "Info.Index.Detail".

It would enhance the documentation to provide a brief description of what "Info.Index.Detail" covers, similar to other sections.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8a36249 and 3bd29e3.
Files ignored due to path filters (10)
  • apis/grpc/v1/manager/index/index_manager.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • apis/grpc/v1/manager/index/index_manager_vtproto.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • apis/grpc/v1/payload/payload.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • apis/grpc/v1/payload/payload.pb.json.go is excluded by !**/*.pb.json.go
  • apis/grpc/v1/payload/payload_vtproto.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • example/client/go.mod is excluded by !**/*.mod
  • example/client/go.sum is excluded by !**/*.sum
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum
  • rust/Cargo.lock is excluded by !**/*.lock
Files selected for processing (42)
  • .github/ISSUE_TEMPLATE/bug_report.md (1 hunks)
  • .github/ISSUE_TEMPLATE/security_issue_report.md (1 hunks)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • Makefile.d/dependencies.mk (1 hunks)
  • Makefile.d/functions.mk (1 hunks)
  • apis/docs/v1/docs.md (3 hunks)
  • apis/proto/v1/manager/index/index_manager.proto (1 hunks)
  • apis/proto/v1/payload/payload.proto (1 hunks)
  • apis/swagger/v1/manager/index/index_manager.swagger.json (2 hunks)
  • hack/go.mod.default (2 hunks)
  • internal/info/info.go (5 hunks)
  • internal/net/grpc/errdetails/errdetails.go (2 hunks)
  • internal/net/http/metrics/pprof.go (2 hunks)
  • internal/observability/trace/status.go (1 hunks)
  • pkg/agent/core/faiss/handler/grpc/insert.go (1 hunks)
  • pkg/agent/core/faiss/handler/grpc/remove.go (1 hunks)
  • pkg/agent/core/faiss/handler/grpc/search.go (1 hunks)
  • pkg/agent/core/faiss/handler/grpc/update.go (1 hunks)
  • pkg/agent/core/ngt/handler/grpc/flush.go (1 hunks)
  • pkg/agent/core/ngt/handler/grpc/insert.go (1 hunks)
  • pkg/agent/core/ngt/handler/grpc/linear_search.go (1 hunks)
  • pkg/agent/core/ngt/handler/grpc/remove.go (1 hunks)
  • pkg/agent/core/ngt/handler/grpc/search.go (1 hunks)
  • pkg/agent/core/ngt/handler/grpc/update.go (1 hunks)
  • pkg/agent/core/ngt/service/ngt_test.go (5 hunks)
  • pkg/manager/index/handler/grpc/handler.go (1 hunks)
  • pkg/manager/index/handler/grpc/handler_test.go (1 hunks)
  • pkg/manager/index/service/indexer.go (8 hunks)
  • pkg/manager/index/service/indexer_test.go (1 hunks)
  • pkg/manager/index/service/option.go (4 hunks)
  • pkg/manager/index/usecase/indexer.go (1 hunks)
  • rust/libs/proto/src/manager.index.v1.tonic.rs (5 hunks)
  • rust/libs/proto/src/payload.v1.rs (1 hunks)
  • versions/GOLANGCILINT_VERSION (1 hunks)
  • versions/K3S_VERSION (1 hunks)
  • versions/KIND_VERSION (1 hunks)
  • versions/NGT_VERSION (1 hunks)
  • versions/PROMETHEUS_STACK_VERSION (1 hunks)
  • versions/YQ_VERSION (1 hunks)
  • versions/actions/CODECOV_CODECOV_ACTION (1 hunks)
  • versions/actions/SOFTPROPS_ACTION_GH_RELEASE (1 hunks)
Files skipped from review due to trivial changes (14)
  • .github/ISSUE_TEMPLATE/bug_report.md
  • .github/ISSUE_TEMPLATE/security_issue_report.md
  • .github/PULL_REQUEST_TEMPLATE.md
  • .github/workflows/release.yml
  • hack/go.mod.default
  • internal/observability/trace/status.go
  • versions/GOLANGCILINT_VERSION
  • versions/K3S_VERSION
  • versions/KIND_VERSION
  • versions/NGT_VERSION
  • versions/PROMETHEUS_STACK_VERSION
  • versions/YQ_VERSION
  • versions/actions/CODECOV_CODECOV_ACTION
  • versions/actions/SOFTPROPS_ACTION_GH_RELEASE
Additional comments not posted (37)
apis/proto/v1/manager/index/index_manager.proto (1)

35-38: The addition of the IndexDetail RPC method is well-defined and aligns with the service's responsibilities.

pkg/manager/index/handler/grpc/handler.go (1)

56-65: The implementation of IndexDetail in the gRPC handler is concise and follows good practices with tracing and error handling.

Verification successful

The LoadIndexDetail method in pkg/manager/index/service/indexer.go initializes and populates a payload.Info_Index_Detail object correctly. There is no explicit error handling, but the logic is straightforward and appears to be implemented correctly.

  • pkg/manager/index/service/indexer.go:356-365
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the implementation of `LoadIndexDetail` method in the indexer interface.

# Test: Search for the method implementation. Expect: Proper error handling and logic.
rg --type go $'LoadIndexDetail'

Length of output: 483



Script:

#!/bin/bash
# Extract the implementation of the LoadIndexDetail method from indexer.go for review.
ast-grep --lang go --pattern $'func (idx *index) LoadIndexDetail() (detail *payload.Info_Index_Detail) {
  $$$
}' pkg/manager/index/service/indexer.go

Length of output: 895

pkg/agent/core/ngt/handler/grpc/flush.go (1)

28-28: The update to the import path for attribute aligns with internal observability practices.

internal/net/http/metrics/pprof.go (1)

120-143: The addition of new profiling routes using pyprof enhances the profiling capabilities of the service.

Verification successful

The search results show the usage of pyprof in defining the routes but do not provide information about their integration into the overall profiling setup. We need to verify if these routes are properly initialized and configured.


The previous search command had a syntax error due to an unclosed group. Let's correct the search pattern and re-run the search to find the initialization or configuration code for the pyprof routes.


The search results show the usage of rest.HandlerToRestFunc(pyprof in defining the routes but do not provide information about their integration into the overall profiling setup. We need to verify if these routes are properly initialized and configured.


The search for http.HandleFunc did not produce any output, indicating that the routes might be registered differently. We need to investigate other possible ways the routes might be registered or initialized.


The search results show various instances of route registration and handler usage, but none directly related to the new pyprof routes. We need to verify if these routes are properly initialized and configured.


The search results show that NewPProfHandler is used in internal/servers/starter/starter.go and cmd/tools/cli/benchmark/core/main.go. We need to verify the usage of NewPProfHandler in these files to ensure proper integration of the new pyprof routes.


The new pyprof routes are properly integrated into the profiling setup. The NewPProfHandler function, which includes the new routes, is used in both internal/servers/starter/starter.go and cmd/tools/cli/benchmark/core/main.go, ensuring that the new profiling capabilities are initialized and configured correctly.

  • internal/servers/starter/starter.go: The NewPProfHandler is used within the setupMetrics function to handle profiling routes.
  • cmd/tools/cli/benchmark/core/main.go: The NewPProfHandler is assigned to the Handler field of an HTTP server, ensuring the routes are served.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of new `pyprof` routes in the profiling setup.

# Test: Search for configuration or initialization code that integrates these routes. Expect: Proper integration and configuration.
rg --type go $'pyprof'

Length of output: 387



Script:

#!/bin/bash
# Description: Verify the integration of new `pyprof` routes in the profiling setup.

# Test: Search for configuration or initialization code that integrates these routes. Expect: Proper integration and configuration.
rg --type go 'rest.HandlerToRestFunc(pyprof'

Length of output: 149



Script:

#!/bin/bash
# Description: Verify the integration of new `pyprof` routes in the profiling setup.

# Test: Search for configuration or initialization code that integrates these routes. Expect: Proper integration and configuration.
rg --type go 'rest.HandlerToRestFunc\(pyprof'

Length of output: 313



Script:

#!/bin/bash
# Description: Verify the integration of new `pyprof` routes in the profiling setup.

# Test: Search for configuration or initialization code that integrates these routes. Expect: Proper integration and configuration.
rg --type go 'http.HandleFunc'

Length of output: 30



Script:

#!/bin/bash
# Description: Verify the integration of new `pyprof` routes in the profiling setup.

# Test: Search for other common patterns used for route registration. Expect: Proper integration and configuration.
rg --type go 'HandleFunc'
rg --type go 'Handle'

Length of output: 60923



Script:

#!/bin/bash
# Description: Verify the integration of new `pyprof` routes in the profiling setup.

# Test: Search for the initialization or configuration code that integrates these routes. Expect: Proper integration and configuration.
rg --type go 'NewPProfHandler'

Length of output: 436



Script:

#!/bin/bash
# Description: Review the usage of `NewPProfHandler` in the relevant files to ensure proper integration of the new `pyprof` routes.

# Test: Display the relevant lines in `internal/servers/starter/starter.go` and `cmd/tools/cli/benchmark/core/main.go`.
rg --type go --context 10 'NewPProfHandler' internal/servers/starter/starter.go
rg --type go --context 10 'NewPProfHandler' cmd/tools/cli/benchmark/core/main.go

Length of output: 1266

pkg/agent/core/faiss/handler/grpc/remove.go (1)

30-30: The update to the import path for attribute aligns with internal observability practices.

pkg/agent/core/faiss/handler/grpc/insert.go (1)

31-31: Import of observability attributes is correctly used for enhanced tracing and logging.

pkg/agent/core/faiss/handler/grpc/update.go (1)

30-30: Import of observability attributes is correctly used for enhanced tracing and logging.

pkg/agent/core/faiss/handler/grpc/search.go (1)

30-30: Import of observability attributes is correctly used for enhanced tracing and logging.

apis/swagger/v1/manager/index/index_manager.swagger.json (1)

15-34: Addition of /index/detail endpoint and IndexDetail schema is correctly implemented and enhances the API documentation.

Also applies to: 83-105

pkg/manager/index/handler/grpc/handler_test.go (1)

217-326: Addition of Test_server_IndexDetail test function is correctly implemented and enhances the testing coverage.

Makefile.d/dependencies.mk (1)

50-51: The dependency addition and the sed command for updating the Go version in go/deps are appropriate and align with the PR's objectives to manage versions more effectively.

internal/net/grpc/errdetails/errdetails.go (1)

Line range hint 329-359: The modifications in DebugInfoFromInfoDetail enhance error handling by clearing the StackTrace after use and improving the logging of JSON marshaling errors. These changes align with the PR's objectives to improve observability and error management.

pkg/agent/core/ngt/handler/grpc/insert.go (1)

29-29: The update in the import path for observability attributes aligns with the PR's objectives to consolidate observability-related functionalities within the internal package, enhancing maintainability.

pkg/manager/index/service/indexer.go (1)

56-60: The additions and modifications in the index struct and its methods enhance the index management capabilities by introducing more control over index saving operations and improving observability. These changes are well-aligned with the PR's objectives.

Also applies to: 69-80, 104-106, 112-116, 151-194, 211-251, 254-287, 344-345, 356-365

internal/info/info.go (4)

51-64: New fields added to the Detail struct enhance system observability and debugging capabilities.


144-156: Updated initialization logic in New function correctly handles the new fields in the Detail struct.


263-268: Updated String method to include new runtime information fields.


384-392: Updated prepare method to initialize new fields based on runtime information.

pkg/agent/core/ngt/handler/grpc/remove.go (1)

29-29: Importing new observability attributes enhances tracing capabilities.

Makefile.d/functions.mk (1)

336-336: Ensure the conditional logic for setting VERSION is robust and handles all expected ACTION_NAME values correctly.

Verification successful

The output indicates that the ACTION_NAME values are being handled in various conditional statements. Here are the key points:

  • The ACTION_NAME is checked for specific values like aquasecurity/trivy-action, machine-learning-apps/actions-chatops, and cirrus-actions/rebase.
  • There are corresponding actions for these specific ACTION_NAME values, such as updating version files and performing sed operations.

To ensure completeness, we need to verify that all possible ACTION_NAME values are covered in the conditional logic. This involves checking if there are any ACTION_NAME values that are used but not handled in the conditional statements.


The previous script failed due to an issue with the grep command's lookbehind assertion. We need to correct this and re-run the script to extract the unique ACTION_NAME values.


The previous attempts to extract ACTION_NAME values using grep did not produce the expected results. We need to adjust our approach to capture these values more effectively. Let's use awk to extract the ACTION_NAME values from the Makefile.


The extracted ACTION_NAME values are:

  • aquasecurity/trivy-action
  • cirrus-actions/rebase
  • security-and-quality

We need to ensure that these values are handled correctly in the conditional logic within the Makefile. Based on the previous context, these values are indeed checked and handled in the conditional statements.

  • aquasecurity/trivy-action and cirrus-actions/rebase are explicitly checked in the conditional logic.
  • security-and-quality is also checked to ensure it is not equal to the ACTION_NAME.

Given this information, it appears that the conditional logic for setting VERSION based on ACTION_NAME is robust and handles all expected values correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all ACTION_NAME values are handled correctly in the update-github-actions function.

# Test: Search for all ACTION_NAME usages. Expect: All usages should have corresponding handling in the conditional block.
rg --type make 'ACTION_NAME' $(fd --type file --name 'functions.mk')

Length of output: 1750



Script:

#!/bin/bash
# Description: Verify that all ACTION_NAME values are handled correctly in the update-github-actions function.

# List all unique ACTION_NAME values used in the Makefile.d/functions.mk
rg --type make 'ACTION_NAME' $(fd --type f -e mk) | grep -oP '(?<=ACTION_NAME\s*=\s*")[^"]+' | sort | uniq

Length of output: 500



Script:

#!/bin/bash
# Description: Verify that all ACTION_NAME values are handled correctly in the update-github-actions function.

# List all unique ACTION_NAME values used in the Makefile.d/functions.mk
rg --type make 'ACTION_NAME' $(fd --type f -e mk) | grep -oP 'ACTION_NAME\s*=\s*"\K[^"]+' | sort | uniq

Length of output: 450



Script:

#!/bin/bash
# Description: Verify that all ACTION_NAME values are handled correctly in the update-github-actions function.

# List all unique ACTION_NAME values used in the Makefile.d/functions.mk
rg --type make 'ACTION_NAME' $(fd --type f -e mk) | awk -F'=' '/ACTION_NAME/ {print $2}' | tr -d ' " ' | sort | uniq

Length of output: 675

pkg/agent/core/ngt/handler/grpc/update.go (2)

29-29: Updated imports for observability are correctly placed and used.


29-29: Proper use of the updated Update function within StreamUpdate ensures consistency in handling GRPC requests.

rust/libs/proto/src/manager.index.v1.tonic.rs (2)

102-102: Implementation of index_info RPC is robust, utilizing tonic's features effectively.


133-133: New index_detail RPC implementation is correctly added and aligns with the PR's objectives to enhance API capabilities.

pkg/agent/core/ngt/handler/grpc/search.go (1)

29-29: Ensure the new observability tools are integrated and configured correctly in the deployment environment.

pkg/agent/core/ngt/handler/grpc/linear_search.go (6)

29-29: Updated import for observability attributes aligns with the PR's objectives.


29-29: Consistent use of updated observability imports across different functions.


29-29: Consistent observability practices in streaming functions enhance maintainability.


29-29: Maintaining consistent error handling and observability in ID-based streaming functions.


29-29: Effective use of concurrency in handling multiple search requests demonstrates good software engineering practices.


29-29: Consistency in handling ID-based search requests concurrently with other search methods.

rust/libs/proto/src/payload.v1.rs (1)

841-853: The addition of the Detail message under the Index message is well-structured and aligns with the requirements for detailed index information. The use of a map for counts is particularly effective for dynamic data association.

apis/docs/v1/docs.md (1)

1182-1185: Verify the implementation of the new RPC method "IndexDetail".

Verification successful

The implementation of the new RPC method "IndexDetail" has been verified successfully. The method is defined and implemented in multiple files, including pkg/manager/index/service/indexer.go and pkg/manager/index/handler/grpc/handler.go.

  • pkg/manager/index/service/indexer.go: Contains the LoadIndexDetail method which is used to load index details.
  • pkg/manager/index/handler/grpc/handler.go: Implements the IndexDetail method in the server struct, which calls LoadIndexDetail.

Additionally, the method is referenced in various other files, confirming its integration into the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the implementation of the new RPC method `IndexDetail`.

# Test: Search for the method implementation. Expect: Implementation details.
rg --type markdown 'IndexDetail' apis/docs/v1/docs.md

Length of output: 241



Script:

#!/bin/bash
# Description: Verify the implementation of the new RPC method `IndexDetail`.

# Test: Search for the method implementation in the source code. Expect: Implementation details.
rg 'IndexDetail' --type not markdown

Length of output: 64



Script:

#!/bin/bash
# Description: Verify the implementation of the new RPC method `IndexDetail`.

# Test: Search for the method implementation in the source code. Expect: Implementation details.
rg 'IndexDetail' --glob '!*.md'

Length of output: 3951

pkg/agent/core/ngt/service/ngt_test.go (4)

41-41: Imports look appropriate for the context.


1559-1560: Changes to the args struct align with enhanced testing capabilities.


1638-1646: Proper use of client and error handling in the test loop.


Line range hint 2-2: Verify the initialization and usage of defaultConfig.

Verification successful

The defaultConfig variable is correctly initialized and used within the pkg/agent/core/ngt/service/ngt_test.go file.

  • pkg/agent/core/ngt/service/ngt_test.go: Initialization and multiple usages of defaultConfig.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the initialization and usage of `defaultConfig`.

# Test: Search for the initialization and usage of `defaultConfig`. Expect: Initialization and usage in the same or related files.
rg --type go $'defaultConfig'

Length of output: 1748

Comment on lines +706 to +849
// indexDuration:nil,
// indexDurationLimit:nil,
// saveIndexDurationLimit:nil,
// saveIndexWaitDuration:nil,
// saveIndexTargetAddrCh:nil,
// schMap:nil,
// concurrency:0,
// indexInfos:nil,
// indexing:nil,
// minUncommitted:0,
// uuidsCount:0,
// uncommittedUUIDsCount:0,
// },
// want: want{},
// checkFunc: defaultCheckFunc,
// beforeFunc: func(t *testing.T,) {
// t.Helper()
// },
// afterFunc: func(t *testing.T,) {
// t.Helper()
// },
// },
// */
//
// // TODO test cases
// /*
// func() test {
// return test {
// name: "test_case_2",
// fields: fields {
// client:nil,
// eg:nil,
// creationPoolSize:0,
// indexDuration:nil,
// indexDurationLimit:nil,
// saveIndexDurationLimit:nil,
// saveIndexWaitDuration:nil,
// saveIndexTargetAddrCh:nil,
// schMap:nil,
// concurrency:0,
// indexInfos:nil,
// indexing:nil,
// minUncommitted:0,
// uuidsCount:0,
// uncommittedUUIDsCount:0,
// },
// want: want{},
// checkFunc: defaultCheckFunc,
// beforeFunc: func(t *testing.T,) {
// t.Helper()
// },
// afterFunc: func(t *testing.T,) {
// t.Helper()
// },
// }
// }(),
// */
// }
//
// for _, tc := range tests {
// test := tc
// t.Run(test.name, func(tt *testing.T) {
// tt.Parallel()
// defer goleak.VerifyNone(tt, goleak.IgnoreCurrent())
// if test.beforeFunc != nil {
// test.beforeFunc(tt)
// }
// if test.afterFunc != nil {
// defer test.afterFunc(tt)
// }
// checkFunc := test.checkFunc
// if test.checkFunc == nil {
// checkFunc = defaultCheckFunc
// }
// idx := &index{
// client: test.fields.client,
// eg: test.fields.eg,
// creationPoolSize: test.fields.creationPoolSize,
// indexDuration: test.fields.indexDuration,
// indexDurationLimit: test.fields.indexDurationLimit,
// saveIndexDurationLimit: test.fields.saveIndexDurationLimit,
// saveIndexWaitDuration: test.fields.saveIndexWaitDuration,
// saveIndexTargetAddrCh: test.fields.saveIndexTargetAddrCh,
// schMap: test.fields.schMap,
// concurrency: test.fields.concurrency,
// indexInfos: test.fields.indexInfos,
// indexing: test.fields.indexing,
// minUncommitted: test.fields.minUncommitted,
// uuidsCount: test.fields.uuidsCount,
// uncommittedUUIDsCount: test.fields.uncommittedUUIDsCount,
// }
//
// gotDetail := idx.LoadIndexDetail()
// if err := checkFunc(test.want, gotDetail); err != nil {
// tt.Errorf("error = %v", err)
// }
//
// })
// }
// }
Copy link
Contributor

@coderabbitai coderabbitai bot May 21, 2024

Choose a reason for hiding this comment

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

Implement the test cases for Test_index_LoadIndexDetail.

The test function is structured correctly but lacks actual test cases. Would you like assistance in implementing these test cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes please

Copy link
Contributor

Choose a reason for hiding this comment

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

@kpango, here are the proposed test cases for the Test_index_LoadIndexDetail function. These tests aim to cover various scenarios including successful data retrieval and error handling:

func Test_index_LoadIndexDetail(t *testing.T) {
    type fields struct {
        client                 discoverer.Client
        eg                     errgroup.Group
        creationPoolSize       uint32
        indexDuration          time.Duration
        indexDurationLimit     time.Duration
        saveIndexDurationLimit time.Duration
        saveIndexWaitDuration  time.Duration
        saveIndexTargetAddrCh  chan string
        schMap                 sync.Map[string, any]
        concurrency            int
        indexInfos             sync.Map[string, *payload.Info_Index_Count]
        indexing               atomic.Value
        minUncommitted         uint32
        uuidsCount             uint32
        uncommittedUUIDsCount  uint32
    }
    type want struct {
        wantDetail *payload.Info_Index_Detail
        err        error
    }
    tests := []struct {
        name    string
        fields  fields
        want    want
    }{
        {
            name: "test_success",
            fields: fields{
                // Initialize fields to simulate a successful state
            },
            want: want{
                wantDetail: &payload.Info_Index_Detail{
                    // Expected details
                },
                err: nil,
            },
        },
        {
            name: "test_error",
            fields: fields{
                // Initialize fields to simulate an error state
            },
            want: want{
                wantDetail: nil,
                err:        errors.New("some error"),
            },
        },
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            idx := &index{
                client:                 tt.fields.client,
                eg:                     tt.fields.eg,
                creationPoolSize:       tt.fields.creationPoolSize,
                indexDuration:          tt.fields.indexDuration,
                indexDurationLimit:     tt.fields.indexDurationLimit,
                saveIndexDurationLimit: tt.fields.saveIndexDurationLimit,
                saveIndexWaitDuration:  tt.fields.saveIndexWaitDuration,
                saveIndexTargetAddrCh:  tt.fields.saveIndexTargetAddrCh,
                schMap:                 tt.fields.schMap,
                concurrency:            tt.fields.concurrency,
                indexInfos:             tt.fields.indexInfos,
                indexing:               tt.fields.indexing,
                minUncommitted:         tt.fields.minUncommitted,
                uuidsCount:             tt.fields.uuidsCount,
                uncommittedUUIDsCount:  tt.fields.uncommittedUUIDsCount,
            }

            gotDetail, err := idx.LoadIndexDetail()
            if !reflect.DeepEqual(gotDetail, tt.want.wantDetail) || !errors.Is(err, tt.want.err) {
                t.Errorf("index.LoadIndexDetail() = %v, want %v, error = %v, wantErr %v", gotDetail, tt.want.wantDetail, err, tt.want.err)
            }
        })
    }
}

This template includes two test cases: one for a successful retrieval of index details and another for handling an error scenario. You might need to adjust the field initializations and expected values based on the actual implementation details and requirements.

Comment on lines +1615 to +1616
addr: "127.0.0.1:8080",
client: grpc.New(grpc.WithInsecure(true)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure grpc.WithInsecure(true) is used only in test environments.

The search results indicate that grpc.WithInsecure(true) and similar insecure configurations are used in various parts of the codebase, including non-test files such as pkg/tools/benchmark/job/usecase/benchmarkd.go, docs/user-guides/filtering-configuration.md, and example/client/mirror/main.go. This suggests that insecure configurations might be present outside of test environments.

  • pkg/tools/benchmark/job/usecase/benchmarkd.go
  • docs/user-guides/filtering-configuration.md
  • example/client/mirror/main.go

Please review these instances to ensure that insecure configurations are not used in production code.

Analysis chain

Ensure grpc.WithInsecure(true) is used only in test environments.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage context of `grpc.WithInsecure(true)`.

# Test: Search for the usage of `grpc.WithInsecure(true)`. Expect: Usage only in test files.
rg --type go $'grpc.WithInsecure(true)'

Length of output: 40



Script:

#!/bin/bash
# Description: Verify the usage context of `grpc.WithInsecure(true)`.

# Test: Search for the usage of `grpc.WithInsecure(true)` across all files.
rg 'grpc.WithInsecure(true)'

Length of output: 30



Script:

#!/bin/bash
# Description: Verify the usage context of insecure gRPC configurations.

# Test: Search for the usage of insecure gRPC configurations across all files.
rg 'WithInsecure'

Length of output: 2578

@kpango kpango force-pushed the refactor/manager-index/small-refactor branch 4 times, most recently from ceec891 to f007c6e Compare May 28, 2024 07:10
@kpango kpango force-pushed the refactor/manager-index/small-refactor branch 5 times, most recently from 73d7926 to 1707dd8 Compare June 18, 2024 08:41
deepsource-autofix bot added a commit that referenced this pull request Jun 18, 2024
This commit fixes the style issues introduced in 73d7926 according to the output
from Gofumpt and Prettier.

Details: #2505
deepsource-autofix bot added a commit that referenced this pull request Jun 18, 2024
This commit fixes the style issues introduced in 1707dd8 according to the output
from Gofumpt and Prettier.

Details: #2505
@kpango kpango force-pushed the refactor/manager-index/small-refactor branch 3 times, most recently from fe32d1c to 63df5f1 Compare June 19, 2024 02:56
@kpango kpango force-pushed the refactor/manager-index/small-refactor branch 2 times, most recently from 1a950eb to bc4566e Compare July 1, 2024 11:09
@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Jul 1, 2024

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

- We have to write all test cases which satisfy `...interface{}` as same as a [basic test case](#Basic). For example, `val = 1`, `val = "input"`, `val = []float64{2020.12}` and so on.
1. When input is not `...interface{}` but `...[]int`, `...[]string` or etc.
1. When input is `...any`
- We have to write all test cases which satisfy `...any` as same as a [basic test case](#Basic). For example, `val = 1`, `val = "input"`, `val = []float64{2020.12}` and so on.
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [documents testlint] <eslint.rules.write-good> reported by reviewdog 🐶
"satisfy" is wordy or unneeded (write-good)

@github-actions github-actions bot removed the size/XXL label Jul 1, 2024
@kpango kpango force-pushed the refactor/manager-index/small-refactor branch 4 times, most recently from 0af8abe to 4d9b217 Compare July 8, 2024 18:59
deepsource-autofix bot added a commit that referenced this pull request Jul 8, 2024
This commit fixes the style issues introduced in 4d9b217 according to the output
from Gofumpt and Prettier.

Details: #2505
@@ -14,7 +14,7 @@ Please also read the [Contribution guideline](../contributing/contributing-guide
Code formatting and naming conventions affect coding readability and maintainability.
Every developer has a different coding style.
Luckily Go provides tools to format source code and check for potential issues in the source code.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) and [crlfmt](https://github.com/cockroachdb/crlfmt) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
Copy link
Contributor

Choose a reason for hiding this comment

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

[documents cspell] reported by reviewdog 🐶
Unknown word (golines) Suggestions: [goonies, gaines, glides, glints, gobies]

@@ -14,7 +14,7 @@ Please also read the [Contribution guideline](../contributing/contributing-guide
Code formatting and naming conventions affect coding readability and maintainability.
Every developer has a different coding style.
Luckily Go provides tools to format source code and check for potential issues in the source code.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) and [crlfmt](https://github.com/cockroachdb/crlfmt) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
Copy link
Contributor

Choose a reason for hiding this comment

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

[documents cspell] reported by reviewdog 🐶
Unknown word (gofumpt) Suggestions: [gout, grump, gazump, gotmpl, grumps]

@@ -14,7 +14,7 @@ Please also read the [Contribution guideline](../contributing/contributing-guide
Code formatting and naming conventions affect coding readability and maintainability.
Every developer has a different coding style.
Luckily Go provides tools to format source code and check for potential issues in the source code.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) and [crlfmt](https://github.com/cockroachdb/crlfmt) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
Copy link
Contributor

Choose a reason for hiding this comment

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

[documents cspell] reported by reviewdog 🐶
Unknown word (goimports) Suggestions: [imports, gompers, gosport, goalposts, gonopores]

@@ -14,7 +14,7 @@ Please also read the [Contribution guideline](../contributing/contributing-guide
Code formatting and naming conventions affect coding readability and maintainability.
Every developer has a different coding style.
Luckily Go provides tools to format source code and check for potential issues in the source code.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) and [crlfmt](https://github.com/cockroachdb/crlfmt) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
Copy link
Contributor

Choose a reason for hiding this comment

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

[documents cspell] reported by reviewdog 🐶
Unknown word (crlfmt) Suggestions: [crlf, craft, croft, cruft, Craft]

kpango pushed a commit that referenced this pull request Jul 8, 2024
This commit fixes the style issues introduced in 4d9b217 according to the output
from Gofumpt and Prettier.

Details: #2505
Signed-off-by: kpango <kpango@vdaas.org>
@kpango kpango force-pushed the refactor/manager-index/small-refactor branch from 6447153 to 431dec7 Compare July 8, 2024 19:01
@@ -14,7 +14,7 @@ Please also read the [Contribution guideline](../contributing/contributing-guide
Code formatting and naming conventions affect coding readability and maintainability.
Every developer has a different coding style.
Luckily Go provides tools to format source code and check for potential issues in the source code.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
We recommend using [golines](https://github.com/segmentio/golines), [gofumpt](https://github.com/mvdan/gofumpt), and [goimports](https://github.com/golang/tools/tree/master/cmd/goimports) and [crlfmt](https://github.com/cockroachdb/crlfmt) to format the source code in Vald and [golangci-lint](https://github.com/golangci/golangci-lint) with the `--enable-all` option.
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [documents testlint] <eslint.rules.en-spell> reported by reviewdog 🐶
crlfmt => craft (en-spell)

@kpango kpango force-pushed the refactor/manager-index/small-refactor branch from 431dec7 to 7459740 Compare July 8, 2024 19:01
…informations

Signed-off-by: kpango <kpango@vdaas.org>
@kpango kpango force-pushed the refactor/manager-index/small-refactor branch from 7459740 to 073c643 Compare July 11, 2024 04:32

| Field | Type | Label | Description |
| ----------- | -------------------------------------------------------------------------- | -------- | ---------------------------------- |
| counts | [Info.Index.Detail.CountsEntry](#payload-v1-Info-Index-Detail-CountsEntry) | repeated | count infos for each agents |
Copy link
Contributor

Choose a reason for hiding this comment

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

[LanguageTool] reported by reviewdog 🐶
The noun should probably be in the singular form. (EVERY_EACH_SINGULAR[1])
Suggestions: agent
URL: https://languagetool.org/insights/post/word-choice-each-and-every/
Rule: https://community.languagetool.org/rule/show/EVERY_EACH_SINGULAR?lang=en-US&subId=1
Category: GRAMMAR

@@ -1480,6 +1485,23 @@ Flush service provides ways to flush all indexed vectors.
| ----------- | ------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------- |
| Flush | [.payload.v1.Flush.Request](#payload-v1-Flush-Request) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | A method to flush all indexed vector. |

<a name="v1_vald_index-proto"></a>

<p align="right"><a href="#top">Top</a></p>
Copy link
Contributor

Choose a reason for hiding this comment

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

[LanguageTool] reported by reviewdog 🐶
Unpaired symbol: ‘"’ seems to be missing (EN_UNPAIRED_QUOTES)
URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses
Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
Category: PUNCTUATION

| Method Name | Request Type | Response Type | Description |
| ----------- | -------------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------- |
| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the index information. |
| IndexDetail | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Detail](#payload-v1-Info-Index-Detail) | Represent the RPC to get the index information for each agents. |
Copy link
Contributor

Choose a reason for hiding this comment

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

[LanguageTool] reported by reviewdog 🐶
The noun should probably be in the singular form. (EVERY_EACH_SINGULAR[1])
Suggestions: agent
URL: https://languagetool.org/insights/post/word-choice-each-and-every/
Rule: https://community.languagetool.org/rule/show/EVERY_EACH_SINGULAR?lang=en-US&subId=1
Category: GRAMMAR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment