Skip to content

Commit

Permalink
chore: disallow MonoVertex replicas less than min or greater than max (
Browse files Browse the repository at this point in the history
  • Loading branch information
whynowy authored Aug 24, 2024
1 parent 86c381f commit 1f2f482
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/reconciler/monovertex/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ func (mr *monoVertexReconciler) reconcile(ctx context.Context, monoVtx *dfv1.Mon
}()

monoVtx.Status.SetObservedGeneration(monoVtx.Generation)
mr.scaler.StartWatching(mVtxKey)
if monoVtx.Scalable() {
mr.scaler.StartWatching(mVtxKey)
}
// TODO: handle lifecycle changes

// Regular mono vertex change
Expand Down Expand Up @@ -155,6 +157,16 @@ func (mr *monoVertexReconciler) reconcileNonLifecycleChanges(ctx context.Context

func (mr *monoVertexReconciler) reconcilePods(ctx context.Context, monoVtx *dfv1.MonoVertex) error {
desiredReplicas := monoVtx.GetReplicas()
// Don't allow replicas to be out of the range of min and max when auto scaling is enabled
if s := monoVtx.Spec.Scale; !s.Disabled {
max := int(s.GetMaxReplicas())
min := int(s.GetMinReplicas())
if desiredReplicas < min {
desiredReplicas = min
} else if desiredReplicas > max {
desiredReplicas = max
}
}
// Set metrics
defer func() {
reconciler.MonoVertexDesiredReplicas.WithLabelValues(monoVtx.Namespace, monoVtx.Name).Set(float64(desiredReplicas))
Expand Down

0 comments on commit 1f2f482

Please sign in to comment.