From af3ce0ccda98ceb5735e9fede644ee29bf093faa Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Thu, 1 Aug 2024 22:46:44 +0600 Subject: [PATCH] Simplify; single flow Signed-off-by: Arnob kumar saha --- pkg/controllers/feature/feature_controller.go | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/pkg/controllers/feature/feature_controller.go b/pkg/controllers/feature/feature_controller.go index bb5f83018..365e81e6d 100644 --- a/pkg/controllers/feature/feature_controller.go +++ b/pkg/controllers/feature/feature_controller.go @@ -338,25 +338,22 @@ func (r *frReconciler) checkRequiredWorkloadExistence(ctx context.Context) (*req } const requiredGroup = "" - for _, w := range groups[requiredGroup] { - status, err := r.checkWorkload(ctx, w) - if err != nil || !status.found || !status.ready { - return status, err - } - } - for _, workloads := range groups { + for group, workloads := range groups { var found, ready bool + if group == requiredGroup { + found, ready = true, true + } for _, w := range workloads { status, err := r.checkWorkload(ctx, w) if err != nil { return status, err - } else if status.found && status.ready { - found = true - ready = true - break } - if status.found { - found = true + if group == requiredGroup { + found = found && status.found + ready = ready && status.ready + } else { + found = found || status.found + ready = ready || status.ready } }