back off to general estimator when scheduler estimator is unavailable
Signed-off-by: Garrybest <garrybest@foxmail.com>
This commit is contained in:
parent
41f1aed2bd
commit
f89e754f2e
|
|
@ -43,7 +43,7 @@ func (se *SchedulerEstimator) MaxAvailableReplicas(clusters []*clusterv1alpha1.C
|
|||
func (se *SchedulerEstimator) maxAvailableReplicas(ctx context.Context, cluster string, replicaRequirements *workv1alpha1.ReplicaRequirements) (int32, error) {
|
||||
client, err := se.cache.GetClient(cluster)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return UnauthenticReplica, err
|
||||
}
|
||||
|
||||
req := &pb.MaxAvailableReplicasRequest{
|
||||
|
|
@ -61,7 +61,7 @@ func (se *SchedulerEstimator) maxAvailableReplicas(ctx context.Context, cluster
|
|||
}
|
||||
res, err := client.MaxAvailableReplicas(ctx, req)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("gRPC request cluster(%s) estimator error: %v", cluster, err)
|
||||
return UnauthenticReplica, fmt.Errorf("gRPC request cluster(%s) estimator error: %v", cluster, err)
|
||||
}
|
||||
return res.MaxReplicas, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import (
|
|||
workv1alpha1 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha1"
|
||||
)
|
||||
|
||||
// UnauthenticReplica is special replica number returned by estimator in case of estimator can't calculate the available
|
||||
// replicas.
|
||||
// The scheduler should discard the estimator's result and back-off to rely on other estimator's result.
|
||||
const UnauthenticReplica = -1
|
||||
|
||||
var (
|
||||
replicaEstimators = map[string]ReplicaEstimator{}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -344,6 +344,9 @@ func (g *genericScheduler) calAvailableReplicas(clusters []*clusterv1alpha1.Clus
|
|||
continue
|
||||
}
|
||||
for i := range res {
|
||||
if res[i].Replicas == estimatorclient.UnauthenticReplica {
|
||||
continue
|
||||
}
|
||||
if availableTargetClusters[i].Name == res[i].Name && availableTargetClusters[i].Replicas > res[i].Replicas {
|
||||
availableTargetClusters[i].Replicas = res[i].Replicas
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue