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: retry when connect to eventbus in sensor #816

Merged
merged 1 commit into from
Aug 6, 2020
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: 8 additions & 2 deletions sensors/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/argoproj/argo-events/common/logging"
"github.com/argoproj/argo-events/eventbus"
eventbusdriver "github.com/argoproj/argo-events/eventbus/driver"
"github.com/argoproj/argo-events/eventsources/sources"
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
sensordependencies "github.com/argoproj/argo-events/sensors/dependencies"
sensortriggers "github.com/argoproj/argo-events/sensors/triggers"
Expand Down Expand Up @@ -102,9 +103,14 @@ func (sensorCtx *SensorContext) ListenEvents(ctx context.Context, stopCh <-chan
for _, t := range triggers {
triggerNames = append(triggerNames, t.Template.Name)
}
conn, err := ebDriver.Connect()
var conn eventbusdriver.Connection
err = sources.Connect(&common.DefaultRetry, func() error {
var err error
conn, err = ebDriver.Connect()
return err
})
if err != nil {
logger.Error("failed to connect to event bus", zap.Error(err))
logger.Fatal("failed to connect to event bus", zap.Error(err))
return
}
defer conn.Close()
Expand Down