Skip to content

Commit 2a8ebf5

Browse files
committed
Added conditional statement for demandPerInstanceType
1 parent 9a39487 commit 2a8ebf5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

controllers/appwrapper_controller.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,21 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request)
102102
if appwrapper.Status.State == arbv1.AppWrapperStateEnqueued || appwrapper.Status.State == "" {
103103
demandPerInstanceType := discoverInstanceTypes(&appwrapper)
104104
//TODO: simplify the looping
105-
if useMachineSets {
106-
if r.canScaleMachineset(ctx, demandPerInstanceType) {
107-
r.scaleUp(ctx, &appwrapper, demandPerInstanceType)
108-
} else {
109-
klog.Infof("Cannot scale up replicas max replicas allowed is %v", maxScaleNodesAllowed)
110-
}
111-
} else {
112-
if canScaleMachinepool(demandPerInstanceType) {
113-
if err := r.scaleUp(ctx, &appwrapper, demandPerInstanceType); err != nil {
114-
return ctrl.Result{}, err
105+
if demandPerInstanceType != nil {
106+
if useMachineSets {
107+
if r.canScaleMachineset(ctx, demandPerInstanceType) {
108+
r.scaleUp(ctx, &appwrapper, demandPerInstanceType)
109+
} else {
110+
klog.Infof("Cannot scale up replicas max replicas allowed is %v", maxScaleNodesAllowed)
115111
}
116112
} else {
117-
klog.Infof("Cannot scale up replicas max replicas allowed is %v", maxScaleNodesAllowed)
113+
if canScaleMachinepool(demandPerInstanceType) {
114+
if err := r.scaleUp(ctx, &appwrapper, demandPerInstanceType); err != nil {
115+
return ctrl.Result{}, err
116+
}
117+
} else {
118+
klog.Infof("Cannot scale up replicas max replicas allowed is %v", maxScaleNodesAllowed)
119+
}
118120
}
119121
}
120122
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)