Skip to content

Commit

Permalink
return before iterating scalers if deployment is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
yaron2 committed May 6, 2019
1 parent a6cf946 commit a44eeba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/handler/scale_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ func (h *ScaleHandler) handleScaleLoop(ctx context.Context, scaledObject *keda_v
// handleScale contains the main logic for the ScaleHandler scaling logic.
// It'll check each trigger active status then call scaleDeployment
func (h *ScaleHandler) handleScale(ctx context.Context, scaledObject *keda_v1alpha1.ScaledObject) {
scalers, deployment := h.getScalers(scaledObject)
if deployment == nil {
return
}

isScaledObjectActive := false

scalers, deployment := h.getScalers(scaledObject)
for _, scaler := range scalers {
isTriggerActive, err := scaler.IsActive(ctx)
if err != nil {
Expand All @@ -231,9 +235,7 @@ func (h *ScaleHandler) handleScale(ctx context.Context, scaledObject *keda_v1alp
scaler.Close()
}

if deployment != nil {
h.scaleDeployment(deployment, scaledObject, isScaledObjectActive)
}
h.scaleDeployment(deployment, scaledObject, isScaledObjectActive)

return
}
Expand Down

0 comments on commit a44eeba

Please sign in to comment.