-
Notifications
You must be signed in to change notification settings - Fork 79
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
Backport PR #2797 to release/v1.7 for Fix validation logic for manager indexer #2814
Conversation
* 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]>
Deploying vald with Cloudflare Pages
|
📝 WalkthroughWalkthroughThe pull request introduces a modification to the conditional logic in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
[CHATOPS:HELP] ChatOps commands.
|
There was a problem hiding this 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
📒 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 toMaxInt64
. 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 inoption.go
simply set the values, and theStart()
method handles negative values by converting them toMaxInt64
. 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 goLength of output: 25994
Codecov ReportAttention: Patch coverage is
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. |
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:
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
Checklist
Special notes for your reviewer
Summary by CodeRabbit
indexDuration
andindexDurationLimit
are non-negative, enhancing error handling for invalid configurations.