Merge pull request #954 from RainbowMango/pr_fix_job_cannot_schedule

Fix job can not schedule issue
This commit is contained in:
karmada-bot 2021-11-12 20:38:31 +08:00 committed by GitHub
commit 81e3b138f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -43,19 +43,18 @@ func (e *DefaultExplorer) HookEnabled(kind schema.GroupVersionKind, operationTyp
// GetReplicas returns the desired replicas of the object as well as the requirements of each replica.
func (e *DefaultExplorer) GetReplicas(object runtime.Object) (int32, *workv1alpha2.ReplicaRequirements, error) {
_, exist := e.replicaHandlers[object.GetObjectKind().GroupVersionKind()]
handler, exist := e.replicaHandlers[object.GetObjectKind().GroupVersionKind()]
if !exist {
return 0, &workv1alpha2.ReplicaRequirements{}, fmt.Errorf("defalut explorer for operation %s not found", configv1alpha1.ExploreReplica)
}
return e.replicaHandlers[appsv1.SchemeGroupVersion.WithKind(util.DeploymentKind)](object)
return handler(object)
}
// GetHealthy tells if the object in healthy state.
func (e *DefaultExplorer) GetHealthy(object runtime.Object) (bool, error) {
// judge object type, and then get correct kind.
_, exist := e.healthyHandlers[appsv1.SchemeGroupVersion.WithKind(util.DeploymentKind)]
handler, exist := e.healthyHandlers[appsv1.SchemeGroupVersion.WithKind(util.DeploymentKind)]
if !exist {
return false, fmt.Errorf("defalut explorer for operation %s not found", configv1alpha1.ExploreHealthy)
}
return e.healthyHandlers[appsv1.SchemeGroupVersion.WithKind(util.DeploymentKind)](object)
return handler(object)
}