refactor: improve config validation in precise-prefix-cache-scorer#690
Open
lisperz wants to merge 1 commit intollm-d:mainfrom
Open
refactor: improve config validation in precise-prefix-cache-scorer#690lisperz wants to merge 1 commit intollm-d:mainfrom
lisperz wants to merge 1 commit intollm-d:mainfrom
Conversation
- Extract hardcoded subscription timeout to named constant - Add validation for pod discovery configuration - Validate socket port range when discoverPods is enabled This prevents runtime panics from invalid configuration and makes the timeout value more maintainable. Signed-off-by: lisperz <zhuchen200245@163.com>
9da6cd2 to
6db2f96
Compare
|
This PR is marked as stale after 21d of inactivity. After an additional 14d of inactivity (7d to become rotten, then 7d more), it will be closed. To prevent this PR from being closed, add a comment or remove the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the
precise-prefix-cache-scorerplugin by adding proper configuration validation and extracting magic numbers to named constants.Changes
Extract hardcoded timeout to constant
defaultSubscriptionTimeoutAdd pod discovery configuration validation
podDiscoveryConfigis present whendiscoverPodsis enabledAdd unit tests
Motivation
Without validation, invalid configurations could cause runtime panics when the scorer tries to access nil pointers or use invalid port numbers. This change catches configuration errors early during plugin initialization with clear error messages.
Testing
go test ./pkg/plugins/scorer -run TestNew_PodDiscoveryValidation -vAll new validation paths are covered by unit tests.