Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions pkg/controller/podautoscaler/podautoscaler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,18 @@ func (r *PodAutoscalerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

if !checkValidAutoscalingStrategy(pa.Spec.ScalingStrategy) {
// TODO: update status or conditions
// this is unrecoverable unless user make changes.
return ctrl.Result{}, nil
apimeta.SetStatusCondition(&pa.Status.Conditions, metav1.Condition{
Type: "AutoscalingStrategy",
Status: metav1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: "AutoscalingStrategyInvalid",
Message: fmt.Sprintf("autoscaling strategy %s is invalid", pa.Spec.ScalingStrategy),
})
return ctrl.Result{}, r.Client.Status().Update(ctx, &pa)
}

if apimeta.RemoveStatusCondition(&pa.Status.Conditions, "AutoscalingStrategy") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to delete a specific AutoscalingStrategy condition here? 🤔

return ctrl.Result{}, r.Client.Status().Update(ctx, &pa)
}

switch pa.Spec.ScalingStrategy {
Expand All @@ -218,12 +227,6 @@ func (r *PodAutoscalerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
case autoscalingv1alpha1.KPA, autoscalingv1alpha1.APA:
return r.reconcileCustomPA(ctx, pa)
}

newStatus := computeStatus(ctx, pa)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to remove the logic here?

if err := r.updateStatusIfNeeded(ctx, newStatus, &pa); err != nil {
return ctrl.Result{}, err
}

return ctrl.Result{}, nil
}

Expand Down