vdaas / vald

Vald. A Highly Scalable Distributed Vector Search Engine
https://vald.vdaas.org
Apache License 2.0
1.51k stars 75 forks source link

Refactor index manager service #2505

Closed kpango closed 1 month ago

kpango commented 3 months ago

Description

Related Issue

Versions

Checklist

Special notes for your reviewer

Summary by CodeRabbit

cloudflare-pages[bot] commented 3 months ago

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: d2877c7
Status: ✅  Deploy successful!
Preview URL: https://ecabd23a.vald.pages.dev
Branch Preview URL: https://refactor-manager-index-small.vald.pages.dev

View logs

coderabbitai[bot] commented 3 months ago

[!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.

165 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) ```mermaid 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 ```

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
vdaas-ci commented 3 months ago

[CHATOPS:HELP] ChatOps commands.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 16.81614% with 1113 lines in your changes missing coverage. Please review.

Project coverage is 18.11%. Comparing base (f3fbbc2) to head (f2a7557). Report is 1 commits behind head on main.

Files Patch % Lines
apis/grpc/v1/payload/payload_vtproto.pb.go 0.00% 316 Missing :warning:
internal/client/v1/client/vald/vald.go 0.00% 153 Missing :warning:
apis/grpc/v1/payload/payload.pb.go 4.76% 140 Missing :warning:
apis/grpc/v1/vald/filter_vtproto.pb.go 0.00% 40 Missing :warning:
apis/grpc/v1/vald/search_vtproto.pb.go 0.00% 40 Missing :warning:
apis/grpc/v1/vald/object_vtproto.pb.go 0.00% 33 Missing :warning:
apis/grpc/v1/vald/index_vtproto.pb.go 0.00% 26 Missing :warning:
internal/net/grpc/errdetails/errdetails.go 0.00% 23 Missing :warning:
internal/net/grpc/status/status.go 19.04% 17 Missing :warning:
internal/net/grpc/client.go 0.00% 15 Missing :warning:
... and 94 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2505 +/- ## ========================================== - Coverage 18.95% 18.11% -0.84% ========================================== Files 565 563 -2 Lines 65225 64200 -1025 ========================================== - Hits 12364 11631 -733 + Misses 52061 51904 -157 + Partials 800 665 -135 ```

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

kpango commented 3 months ago

@coderabbitai Can you fix the test failure?

coderabbitai[bot] commented 3 months ago

Oops, something went wrong! Please try again later. :rabbit: :broken_heart:

kpango commented 3 months ago

@coderabbitai internal/info/info.go and its test internal/info/info_test.go is failing, can you fix it?

coderabbitai[bot] commented 3 months ago

Fixes for internal/info/info.go

  1. Ensure that the info struct is correctly initialized with all required fields.
  2. Update the prepare method to initialize all fields in the Detail struct.
  3. Ensure that the String and Get methods return the expected results.

Fixes for internal/info/info_test.go

  1. Update the test functions to correctly validate the behavior of the info and Detail structs.
  2. Ensure that the test functions handle any edge cases and unexpected inputs.

Here are the proposed changes:

internal/info/info.go

// Ensure that the prepare method initializes all fields in the Detail struct.
func (i *info) prepare() {
    i.prepOnce.Do(func() {
        if i.detail.GitCommit == "" {
            i.detail.GitCommit = "main"
        }
        if Version == "" && i.detail.Version == "" {
            i.detail.Version = GitCommit
        }
        if i.detail.BuildTime == "" {
            i.detail.BuildTime = BuildTime
        }
        if i.detail.GoVersion == "" {
            i.detail.GoVersion = runtime.Version()
        }
        if i.detail.GoOS == "" {
            i.detail.GoOS = runtime.GOOS
        }
        if i.detail.GoArch == "" {
            i.detail.GoArch = runtime.GOARCH
        }
        if i.detail.GoRoot == "" {
            i.detail.GoRoot = runtime.GOROOT()
        }
        if i.detail.CGOEnabled == "" && CGOEnabled != "" {
            i.detail.CGOEnabled = CGOEnabled
        }
        switch i.detail.CGOEnabled {
        case "0", cgoFalse:
            i.detail.CGOEnabled = cgoFalse
        case "1", cgoTrue:
            i.detail.CGOEnabled = cgoTrue
        default:
            i.detail.CGOEnabled = cgoUnknown
        }
        if i.detail.AlgorithmInfo == "" && AlgorithmInfo != "" {
            i.detail.AlgorithmInfo = AlgorithmInfo
        }
        if len(i.detail.BuildCPUInfoFlags) == 0 && BuildCPUInfoFlags != "" {
            i.detail.BuildCPUInfoFlags = strings.Split(strings.TrimSpace(BuildCPUInfoFlags), " ")
        }
        if i.baseURL == "" {
            i.baseURL = "https://" + valdRepo + "/tree/" + i.detail.GitCommit
        }
        if len(i.detail.GoMaxProcs) == 0 {
            i.detail.GoMaxProcs = strconv.Itoa(runtime.GOMAXPROCS(-1))
        }
        if len(i.detail.CGOCall) == 0 {
            i.detail.CGOCall = strconv.FormatInt(runtime.NumCgoCall(), 10)
        }
        if len(i.detail.GoroutineCount) == 0 {
            i.detail.GoroutineCount = strconv.Itoa(runtime.NumGoroutine())
        }
    })
}

internal/info/info_test.go

func TestString(t *testing.T) {
    type want struct {
        want string
    }
    type test struct {
        name       string
        want       want
        checkFunc  func(want, string) error
        beforeFunc func(*testing.T)
        afterFunc  func(*testing.T)
    }
    defaultCheckFunc := func(w want, got string) error {
        if got != w.want {
            return errors.Errorf("got: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want)
        }
        return nil
    }
    tests := []test{
        {
            name: "return string representation of Detail",
            want: want{
                want: "expected string representation",
            },
            checkFunc: defaultCheckFunc,
        },
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            if tt.beforeFunc != nil {
                tt.beforeFunc(t)
            }
            if tt.afterFunc != nil {
                defer tt.afterFunc(t)
            }
            got := String()
            if err := tt.checkFunc(tt.want, got); err != nil {
                t.Errorf("String() error = %v", err)
            }
        })
    }
}

@kpango, I have proposed fixes for the issues in internal/info/info.go and internal/info/info_test.go. Please review the changes and let me know if you need any further adjustments.

[ADD_LEARNING] The internal/info/info.go file defines the Info interface, info struct, and Detail struct, along with their methods. The prepare method initializes all fields in the Detail struct.

[ADD_LEARNING] The test functions in internal/info/info_test.go cover various aspects of the info and Detail structs, including initialization, string representation, and retrieval of details. The error messages indicate that there are multiple instances where errors are being checked and reported.

Analysis chain --- ---
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Run the tests and capture the output to identify the specific failures in internal/info/info_test.go go test ./internal/info/... -v ``` Length of output: 102 --- --- Script: ```shell #!/bin/bash # Search for test functions in internal/info/info_test.go rg 'func Test' internal/info/info_test.go # Search for error messages in internal/info/info_test.go rg 'Error' internal/info/info_test.go ``` Length of output: 1743 --- --- Script: ```shell #!/bin/bash # Extract the code of the test functions in internal/info/info_test.go rg -A 20 'func Test' internal/info/info_test.go # Extract the code in internal/info/info.go cat internal/info/info.go ``` Length of output: 17536
Actions Performed Review triggered. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
vdaas-ci commented 2 months ago

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