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

Backport PR #2797 to release/v1.7 for Fix validation logic for manager indexer #2814

Merged

Conversation

vdaas-ci
Copy link
Collaborator

@vdaas-ci vdaas-ci commented Jan 27, 2025

Description

It appears that the current validation does not account for cases where saveIndexDurationLimit might be set to a significantly large negative value (e.g., -1h). This could inadvertently result in valid configurations being flagged as errors.

Even when indexDuration, indexDurationLimit, and saveIndexDurationLimit are all set to negative values, the system assigns MaxInt64 at startup, ensuring that an index creation will eventually occur. Because of this, I wonder if this validation is strictly necessary.

If the goal is to detect only configurations where index duration is effectively disabled, we could modify the validation to:

if i.indexDuration <= 0 && i.indexDurationLimit <= 0 && i.saveIndexDurationLimit <= 0 {
    return nil, errors.ErrInvalidConfig
}

This way, the validation triggers an error only when all three parameters are negative.

As I do not have full context on the original intent behind this validation, I would appreciate any insights or corrections if I am misunderstanding its purpose.

Related Issue

Versions

  • Vald Version: v1.7.15
  • Go Version: v1.23.4
  • Rust Version: v1.83.0
  • Docker Version: v27.4.0
  • Kubernetes Version: v1.32.0
  • Helm Version: v3.16.3
  • NGT Version: v2.3.5
  • Faiss Version: v1.9.0

Checklist

Special notes for your reviewer

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation logic for configuration duration parameters to ensure both indexDuration and indexDurationLimit are non-negative, enhancing error handling for invalid configurations.

* fix validation logic for manager indexer

Signed-off-by: aknishid <[email protected]>

* Change validation to include zero.

Signed-off-by: aknishid <[email protected]>

---------

Signed-off-by: aknishid <[email protected]>
Co-authored-by: Kiichiro YUKAWA <[email protected]>
Copy link

cloudflare-workers-and-pages bot commented Jan 27, 2025

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5389569
Status: ✅  Deploy successful!
Preview URL: https://a056236e.vald.pages.dev
Branch Preview URL: https://backport-release-v1-7-bug-ma.vald.pages.dev

View logs

Copy link
Contributor

coderabbitai bot commented Jan 27, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a modification to the conditional logic in the New function of the index struct within the pkg/manager/index/service/indexer.go file. The change alters the validation criteria for checking index duration parameters. Specifically, the original condition has been updated to check if both indexDuration and indexDurationLimit are less than or equal to zero, while maintaining the existing check for saveIndexDurationLimit. This refinement potentially changes how the initialization of the index struct handles configuration parameters.

Changes

File Change Summary
pkg/manager/index/service/indexer.go Modified validation logic in New function, adjusting the condition for checking index duration parameters

Possibly related PRs

Suggested labels

priority/low, actions/e2e-deploy

Suggested reviewers

  • kpango
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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 Author

[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

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: 0

🧹 Nitpick comments (1)
pkg/manager/index/service/indexer.go (1)

Line range hint 94-106: Document the handling of negative duration values.

The code correctly handles negative duration values by converting them to MaxInt64, but this behavior isn't documented. Consider adding a comment explaining this behavior for future maintainers.

+	// Convert negative duration values to MaxInt64 to effectively disable the limits
 	if idx.indexDuration <= 0 {
 		idx.indexDuration = math.MaxInt64
 	}
 	if idx.indexDurationLimit <= 0 {
 		idx.indexDurationLimit = math.MaxInt64
 	}
 	if idx.saveIndexDuration <= 0 {
 		idx.saveIndexDuration = math.MaxInt64
 	}
 	if idx.saveIndexDurationLimit <= 0 {
 		idx.saveIndexDurationLimit = math.MaxInt64
 	}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 814e131 and 5389569.

📒 Files selected for processing (1)
  • pkg/manager/index/service/indexer.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build / build
  • GitHub Check: Analyze (go)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
pkg/manager/index/service/indexer.go (1)

79-81: LGTM! The validation logic now correctly matches runtime behavior.

The updated validation logic properly aligns with how negative values are handled in the Start method, where they are converted to MaxInt64. This change prevents false positives when some duration parameters are negative, which is a valid configuration.

Let's verify that this is the only validation check for these parameters:

✅ Verification successful

Validation check is correctly placed and is the only one in the codebase.

The search confirms that the validation in New() method is the only check for these duration parameters. The option setters in option.go simply set the values, and the Start() method handles negative values by converting them to MaxInt64. This centralized validation approach is clean and effective.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other validation checks on these parameters
rg -A 3 "indexDuration|indexDurationLimit|saveIndexDurationLimit" --type go

Length of output: 25994

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (release/v1.7@814e131). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/manager/index/service/indexer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             release/v1.7    #2814   +/-   ##
===============================================
  Coverage                ?   23.92%           
===============================================
  Files                   ?      546           
  Lines                   ?    54555           
  Branches                ?        0           
===============================================
  Hits                    ?    13050           
  Misses                  ?    40720           
  Partials                ?      785           

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

@vankichi vankichi merged commit b1b7bdd into release/v1.7 Jan 27, 2025
46 of 48 checks passed
@vankichi vankichi deleted the backport/release/v1.7/bug/manager/fix-validation branch January 27, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants