Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com>

Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
  • Loading branch information
coderanger committed Jan 5, 2021
1 parent 4eb4cb0 commit abcf8bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/scaling/executor/scale_scaledobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (e *scaleExecutor) RequestScale(ctx context.Context, scaledObject *kedav1al
"scaledObject.Namespace", scaledObject.Namespace,
"scaleTarget.Name", scaledObject.Spec.ScaleTargetRef.Name)

// Get the current replica count. As a special case, Deployments fetch directly from the object so they can use the informer cache
// Get the current replica count. As a special case, Deployments and StatefulSets fetch directly from the object so they can use the informer cache
// to reduce API calls. Everything else uses the scale subresource.
var currentScale *autoscalingv1.Scale
var currentReplicas int32
Expand All @@ -28,23 +28,23 @@ func (e *scaleExecutor) RequestScale(ctx context.Context, scaledObject *kedav1al
deployment := &appsv1.Deployment{}
err := e.client.Get(ctx, client.ObjectKey{Name: targetGVKR.Resource, Namespace: scaledObject.Namespace}, deployment)
if err != nil {
logger.Error(err, "Error getting information on the current Scale (ie. replias count) on the scaleTarget")
logger.Error(err, "Error getting information on the current Scale (ie. replicas count) on the scaleTarget")
return
}
currentReplicas = *deployment.Spec.Replicas
case targetGVKR.Group == "apps" && targetGVKR.Kind == "StatefulSet":
statefulSet := &appsv1.StatefulSet{}
err := e.client.Get(ctx, client.ObjectKey{Name: targetGVKR.Resource, Namespace: scaledObject.Namespace}, statefulSet)
if err != nil {
logger.Error(err, "Error getting information on the current Scale (ie. replias count) on the scaleTarget")
logger.Error(err, "Error getting information on the current Scale (ie. replicas count) on the scaleTarget")
return
}
currentReplicas = *statefulSet.Spec.Replicas
default:
var err error
currentScale, err = e.getScaleTargetScale(ctx, scaledObject)
if err != nil {
logger.Error(err, "Error getting information on the current Scale (ie. replias count) on the scaleTarget")
logger.Error(err, "Error getting information on the current Scale (ie. replicas count) on the scaleTarget")
return
}
currentReplicas = currentScale.Spec.Replicas
Expand Down

0 comments on commit abcf8bb

Please sign in to comment.