Skip to content

Commit

Permalink
sentry retry up to 30s (dapr#7508)
Browse files Browse the repository at this point in the history
Signed-off-by: yaron2 <schneider.yaron@live.com>
  • Loading branch information
yaron2 authored and JoshVanL committed Mar 6, 2024
1 parent 897cb47 commit 8f5e261
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions cmd/injector/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ func Run() {
if err != nil {
return rerr
}
requester := sentry.New(sentry.Options{
requester, derr := sentry.New(ctx, sentry.Options{
SentryAddress: cfg.SentryAddress,
SentryID: sentryID,
Security: sec,
})
derr := requester.DialSentryConnection(ctx)
if derr != nil {
return derr
}
Expand Down
12 changes: 7 additions & 5 deletions pkg/injector/sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ type Requester struct {
}

// New returns a new instance of the Requester.
func New(opts Options) *Requester {
func New(ctx context.Context, opts Options) (*Requester, error) {
_, kubeMode := os.LookupEnv("KUBERNETES_SERVICE_HOST")
return &Requester{
r := &Requester{
sentryAddress: opts.SentryAddress,
sentryID: opts.SentryID,
sec: opts.Security,
kubernetesMode: kubeMode,
}

return r, r.dialSentryConnection(ctx)
}

// DialSentryConnection creates the gRPC connection to the Sentry service and blocks for 1 minute.
func (r *Requester) DialSentryConnection(ctx context.Context) error {
// dialSentryConnection creates the gRPC connection to the Sentry service and blocks for 1 minute.
func (r *Requester) dialSentryConnection(ctx context.Context) error {
connCtx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()

Expand Down Expand Up @@ -109,7 +111,7 @@ func (r *Requester) RequestCertificateFromSentry(ctx context.Context, namespace
Token: token,
Namespace: namespace,
TokenValidator: tokenValidator,
}, grpcRetry.WithMax(3), grpcRetry.WithPerRetryTimeout(time.Second*3))
}, grpcRetry.WithMax(10), grpcRetry.WithPerRetryTimeout(time.Second*3))
if err != nil {
return nil, nil, fmt.Errorf("error from sentry SignCertificate: %w", err)
}
Expand Down

0 comments on commit 8f5e261

Please sign in to comment.