From 85d86041d6c050eefc771a78973f25433cee21c6 Mon Sep 17 00:00:00 2001 From: Eoin Gallinagh Date: Mon, 11 Dec 2023 19:47:08 +0000 Subject: [PATCH] add: appwrapper condition check for scale-up --- controllers/appwrapper_controller.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/controllers/appwrapper_controller.go b/controllers/appwrapper_controller.go index 5f35450..1a9bff1 100644 --- a/controllers/appwrapper_controller.go +++ b/controllers/appwrapper_controller.go @@ -120,17 +120,24 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, nil } - demandPerInstanceType := r.discoverInstanceTypes(ctx, &appwrapper) - if ocmSecretRef := r.Config.OCMSecretRef; ocmSecretRef != nil { - return r.scaleMachinePool(ctx, &appwrapper, demandPerInstanceType) - } else { - switch strings.ToLower(r.Config.MachineSetsStrategy) { - case "reuse": - return r.reconcileReuseMachineSet(ctx, &appwrapper, demandPerInstanceType) - case "duplicate": - return r.reconcileCreateMachineSet(ctx, &appwrapper, demandPerInstanceType) + status := appwrapper.Status.State + allconditions := appwrapper.Status.Conditions + for _, condition := range allconditions { + if status == "Pending" && strings.Contains(condition.Message, "Insufficient") { + demandPerInstanceType := r.discoverInstanceTypes(ctx, &appwrapper) + if ocmSecretRef := r.Config.OCMSecretRef; ocmSecretRef != nil { + return r.scaleMachinePool(ctx, &appwrapper, demandPerInstanceType) + } else { + switch strings.ToLower(r.Config.MachineSetsStrategy) { + case "reuse": + return r.reconcileReuseMachineSet(ctx, &appwrapper, demandPerInstanceType) + case "duplicate": + return r.reconcileCreateMachineSet(ctx, &appwrapper, demandPerInstanceType) + } + } } } + return ctrl.Result{}, nil }