Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust connection for custom gRPC trigger #3421

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/sensors/triggers/custom-trigger/custom-trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading