-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
Optimize Repeated registration of AlgorithmProvider when ApplyFeatureGates #54047
Conversation
Hi @kuramal. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
Looks good to me. Just minor comments.
validateAlgorithmNameOrDie(providerName) | ||
provider, ok := algorithmProviderMap[providerName] | ||
if !ok { | ||
return fmt.Errorf("plugin %q has not been registered", providerName) |
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.
s/%q/%v/
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.
corrected
validateAlgorithmNameOrDie(providerName) | ||
provider, ok := algorithmProviderMap[providerName] | ||
if !ok { | ||
return fmt.Errorf("plugin %q has not been registered", providerName) |
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.
s/%q/%v/
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.
corrected
@bsalamat updated |
@k82cn Could you please take a look at this PR as well? |
/assign sure, I'll review it recently :). |
@kuramal , thanks very much for your contribution :). The logic of this PR is correct, but my concern is that someone may miss |
@k82cn, is there any case that apply different feature for providers? In fact, I can apply all providers with range algorithmProviderMap[]. |
no for now :). If someone add a new provider in future, he may miss this part; so it's better to have a central place to add new provider. This PR is correct; just thinking if we can do it better :). |
/ok-to-test |
@k82cn, I can use algorithmProviderMap[] as a central place, but when ApplyFeatureGates runs, it will apply all providers, no matter it is registered by registerAlgorithmProvider() or not. Or add a new algorithmProviderList[] which store the providers registered by registerAlgorithmProvider(). |
@k82cn ? |
The first option is ok to me :). IMO, it's ok to have some overlap or overwrite; we just need to make sure it's "clear" with enough comments. |
…Gates Add InsertPredicateKeyToAlgorithmProviderMap() and RemovePredicateKeyFromAlgorithmProviderMap() to insert/remove fit predicate key of all algorithmProviders which in algorithmProviderMap Add Func RemovePredicateKeyFromAlgoProvider() AND InsertPredicateKeyToAlgoProvider() which can insert/remove fit predicate key to specific algorithmProvider
@k82cn updated |
|
||
glog.Warningf("TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory") | ||
} | ||
|
||
registerAlgorithmProvider(predSet, defaultPriorities()) |
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.
can you also help to rollback this func?
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.
@k82cn Hi, what does rollback this func mean? could you let me be more specific?
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.
remove registerAlgorithmProvider
definition :).
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.
func init() {
...
registerAlgorithmProvider(defaultPredicates(), defaultPriorities())
...
}
The func registerAlgorithmProvider is using register algorithm provider, it is called when package defaults loading.
remove registerAlgorithmProvider() ?!
@k82cn
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.
ok.
LGTM overall , thanks very much :). |
/lgtm |
/approve no-issue |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: k82cn, kuramal Associated issue requirement bypassed by: k82cn The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
modified ApplyFeatureGates() just add/del features, cancel the register of all AlgorithmProvider.
there is Repeated registration of all AlgorithmProvider when ApplyFeatureGates() runs;
AlgorithmProvider have already registered when package defaults loaded;
I think ApplyFeatureGates() is just add/del features, it needn't register all AlgorithmProvider again
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Release note: