Fix the issue of unable to complete scaling down from 1 to 0.
This commit is contained in:
parent
543e02a413
commit
66598607c9
|
|
@ -16,10 +16,24 @@ type ExternalScaler struct {
|
|||
func (e *ExternalScaler) mustEmbedUnimplementedExternalScalerServer() {
|
||||
}
|
||||
|
||||
func (e *ExternalScaler) IsActive(ctx context.Context, scaledObject *ScaledObjectRef) (*IsActiveResponse, error) {
|
||||
return &IsActiveResponse{
|
||||
Result: true,
|
||||
}, nil
|
||||
func (e *ExternalScaler) IsActive(ctx context.Context, scaledObjectRef *ScaledObjectRef) (*IsActiveResponse, error) {
|
||||
name := scaledObjectRef.GetName()
|
||||
ns := scaledObjectRef.GetNamespace()
|
||||
gss := &gamekruiseiov1alpha1.GameServerSet{}
|
||||
err := e.client.Get(ctx, types.NamespacedName{Namespace: ns, Name: name}, gss)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
return nil, err
|
||||
}
|
||||
currentReplicas := gss.Status.CurrentReplicas
|
||||
numWaitToBeDeleted := gss.Status.WaitToBeDeletedReplicas
|
||||
if numWaitToBeDeleted == nil {
|
||||
return nil, fmt.Errorf("GameServerSet %s/%s has not inited", ns, name)
|
||||
}
|
||||
desireReplicas := currentReplicas - *numWaitToBeDeleted
|
||||
return &IsActiveResponse{
|
||||
Result: desireReplicas > 0,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e *ExternalScaler) StreamIsActive(scaledObject *ScaledObjectRef, epsServer ExternalScaler_StreamIsActiveServer) error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue