From a80f1df327c587ed6869601b88f5c9a4dc2f048c Mon Sep 17 00:00:00 2001 From: Thomas Newton Date: Thu, 4 Apr 2024 08:50:54 +0100 Subject: [PATCH] Make it work with defer Signed-off-by: Thomas Newton --- flytepropeller/pkg/controller/handler.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flytepropeller/pkg/controller/handler.go b/flytepropeller/pkg/controller/handler.go index 03b6494751..675c82d317 100644 --- a/flytepropeller/pkg/controller/handler.go +++ b/flytepropeller/pkg/controller/handler.go @@ -230,6 +230,7 @@ func (p *Propeller) Handle(ctx context.Context, namespace, name string) error { } streak := 0 + defer func() { p.metrics.StreakLength.Add(ctx, float64(streak)) }() maxLength := p.cfg.MaxStreakLength if maxLength <= 0 { @@ -238,15 +239,16 @@ func (p *Propeller) Handle(ctx context.Context, namespace, name string) error { for streak = 0; streak < maxLength; streak++ { w, err = p.streak(ctx, w, wfClosureCrdFields) - if err != nil || w == nil { + if err != nil { + return err + } else if w == nil { break } logger.Infof(ctx, "FastFollow Enabled. Detected State change, we will try another round. StreakLength [%d]", streak) } logger.Infof(ctx, "Streak ended at [%d]/Max: [%d]", streak, maxLength) - p.metrics.StreakLength.Add(ctx, float64(streak)) - return err + return nil } // parseWorkflowClosureCrdFields attempts to retrieve offloaded static workflow closure data from the specified