-
Notifications
You must be signed in to change notification settings - Fork 111
feat: Add factory functions for all plugins #208
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
Conversation
|
verifying - was this tested e2e? |
| ) | ||
|
|
||
| type loadAwareScorerParameters struct { | ||
| Threshold float64 `json:"threshold"` |
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.
should be int
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.
The threshold here is a float64. It was read from an environment variable and converted to a float64
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.
sorry. saw in the old code GetEnvInt and confused. but in old code in was also converted into float64.
does it make sense that queue length is float and not int? shouldn't we treat queue length as int?
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.
You're probably right. It may be stored as a float64 just to avoid constantly casting the value in calculations.
I made the field an int.
pkg/plugins/scorer/kvcache_aware.go
Outdated
| RedisAddres string `json:"redisAddress"` | ||
| HfToken string `json:"hfToken"` |
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.
don't you think this is problematic?
putting personal access token or connection string that includes password, in a configuration file?
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.
I revered the code here. These two fields are again fetched from environment variables
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.
thanks.
I recommend also adding a comment about sensitive information in GIE Config API documentation. e.g., something like:
it's not recommended to store sensitive information in the plugin configuration and this kind of information should be stored differently (e.g., using env vars).*not related to this PR.
pkg/plugins/register.go
Outdated
|
|
||
| // RegisterAllPlugins registers the factory functions of all plugins in this repository. | ||
| func RegisterAllPlugins() { | ||
| plugins.Register(filter.ByLabelsFilterType, filter.ByLabelFactory) |
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.
why do we register an example filter only for documentation purpose?
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.
I registered all of the plugins
| rawPlugin := handle.Plugins().Plugin(parameters.PrefixScorerRef) | ||
| if rawPlugin == nil { | ||
| return nil, fmt.Errorf("there was no plugin with the name '%s' defined", parameters.PrefixScorerRef) | ||
| } |
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.
this is why I suggested returning in GIE (rawPlugin, bool). this check shouldn't be in the responsibility of a config api consumer, this error should return from GIE.
not a big deal and certainly not a blocker, but I think this should be changed in GIE. otherwise, every plugin that may have ref to another plugin would need to write the error (and potentially different developers might write the error differently, making it harder to debug due to inconsistencies in the log).
| rawPlugin := handle.Plugins().Plugin(parameters.PrefixScorerRef) | ||
| if rawPlugin == nil { | ||
| return nil, fmt.Errorf("there was no plugin with the name '%s' defined", parameters.PrefixScorerRef) | ||
| } | ||
| prefixScorer, ok := rawPlugin.(*scorer.PrefixAwareScorer) | ||
| if !ok { | ||
| return nil, fmt.Errorf("the plugin with the name '%s' was not an instance of the PrefixAwareScorer", parameters.PrefixScorerRef) | ||
| } |
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.
all this logic can be implemented as generic function inside GIE, reducing the necessity to do the same code every time a plugin is referencing a different plugin.
see an example here:
https://github.com/kubernetes-sigs/gateway-api-inference-extension/blob/main/pkg/epp/scheduling/types/cycle_state.go#L97-L111
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.
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.
Updated code to use GIE helper
Not yet. This PR only adds the factory functions and registers them. The idea was to break things up into smaller chunks to make it easier to review. |
0caf38d to
640b3f1
Compare
Signed-off-by: Shmuel Kallner <[email protected]>
Signed-off-by: Shmuel Kallner <[email protected]>
Signed-off-by: Shmuel Kallner <[email protected]>
Signed-off-by: Shmuel Kallner <[email protected]>
| return nil, errors.New("ByLabels: missing filter name") | ||
| return nil, errors.New("ByLabelSelector: missing filter name") |
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.
why is it mandatory to specify name?
it's optional in all other plugins..
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.
cc @mayabar
| parameters := pdProfileHandlerParameters{ | ||
| Config: prefix.Config{ | ||
| HashBlockSize: prefix.DefaultHashBlockSize, | ||
| MaxPrefixBlocksToMatch: prefix.DefaultMaxPrefixBlocks, | ||
| LRUCapacityPerServer: prefix.DefaultLRUCapacityPerServer, | ||
| }, |
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.
does it make sense that prefix config appear on profile handler plugin?
shouldn't it appear on prefix plugin only?
something with this configuration looks not natural..
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.
This configuration is from the previous change to eliminate our own Prefix Scorer
| } | ||
| return NewPdProfileHandler(cfg).WithName(name), nil | ||
| } | ||
|
|
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.
comment on line 114 (I can't put the comment there cause it wasn't change in this PR):
prefixState, err := types.ReadCycleStateKey[*prefix.SchedulingContextState](cycleState, prefix.PrefixCachePluginType)
if err != nil {
log.FromContext(ctx).Error(err, "unable to read prefix state")
return map[string]*framework.SchedulerProfile{}
}if this the expected behavior? if the prefix scorer failed to write the prefix we don't do PD?
cc @kfirtoledo
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.
This code is from the previous change to eliminate our own Prefix Scorer
| MaxPrefixBlocksToMatch: prefix.DefaultMaxPrefixBlocks, | ||
| LRUCapacityPerServer: prefix.DefaultLRUCapacityPerServer, |
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.
is profile handler using these values?
nirrozenbaum
left a comment
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.
/lgtm
/approve
PR looks great, thanks!
I left two non-blocking minor comments/questions, one for @mayabar and one for @kfirtoledo that could be addressed (if needed?) in follow ups.
Signed-off-by: konflux-internal-p02 <170854209+konflux-internal-p02[bot]@users.noreply.github.com> Co-authored-by: konflux-internal-p02[bot] <170854209+konflux-internal-p02[bot]@users.noreply.github.com>
This PR:
This PR completes steps three and four of issue #201