From e4eaea57f62f41a38c8e70727fb57cb0774d2865 Mon Sep 17 00:00:00 2001 From: Michael Weibel <307427+mweibel@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:10:03 +0100 Subject: [PATCH] fix: adjust connection for custom gRPC trigger (#3421) Signed-off-by: Michael Weibel --- pkg/sensors/triggers/custom-trigger/custom-trigger.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/sensors/triggers/custom-trigger/custom-trigger.go b/pkg/sensors/triggers/custom-trigger/custom-trigger.go index aea60ee5d0..71fe0e14a7 100644 --- a/pkg/sensors/triggers/custom-trigger/custom-trigger.go +++ b/pkg/sensors/triggers/custom-trigger/custom-trigger.go @@ -97,21 +97,25 @@ func NewCustomTrigger(sensor *v1alpha1.Sensor, trigger *v1alpha1.Trigger, logger opt..., ) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to connect to trigger server: %w", err) } backoff, err := sharedutil.Convert2WaitBackoff(&sharedutil.DefaultBackoff) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to convert wait backoff: %w", err) } if err = wait.ExponentialBackoff(*backoff, func() (done bool, err error) { + logger.Debugw("waiting for trigger client connection...", "server-url", ct.ServerURL, "err", err, "state", conn.GetState().String()) + if conn.GetState() == connectivity.Idle { + conn.Connect() + } if conn.GetState() == connectivity.Ready { return true, nil } return false, nil }); err != nil { - return nil, err + return nil, fmt.Errorf("failed to connect to trigger server: %w", err) } customTrigger.triggerClient = triggers.NewTriggerClient(conn)