Skip to content

Commit

Permalink
ns: Update retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Oct 27, 2023
1 parent ed86bd7 commit 520de4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
5 changes: 4 additions & 1 deletion pkg/networkserver/grpc_asns.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func (ns *NetworkServer) processApplicationUplinkTask(ctx context.Context, consu
}
cl := ttnpb.NewNsAsClient(conn)
if err := ns.sendApplicationUplinks(ctx, cl, ups...); err != nil {
log.FromContext(ctx).WithError(err).Error("Failed to send application uplinks")
log.FromContext(ctx).WithError(err).Warn("Failed to send application uplinks")
if !retryableUplinkError(err) {
return nil
}
return err
}
return nil
Expand Down
17 changes: 5 additions & 12 deletions pkg/networkserver/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,6 @@ func (ns *NetworkServer) submitApplicationUplinks(ctx context.Context, ups ...*t
))
if err := ns.uplinkSubmissionPool.Publish(ctx, ups); err != nil {
log.FromContext(ctx).WithError(err).Warn("Failed to enqueue application uplinks in submission pool")
if nonRetryableUplinkError(err) {
log.FromContext(ctx).Warn("Error is non-retryable, dropping application uplinks")
return
}
ns.enqueueApplicationUplinks(ctx, ups...)
return
}
Expand All @@ -430,8 +426,7 @@ func (ns *NetworkServer) handleUplinkSubmission(ctx context.Context, ups []*ttnp
}
if err := ns.sendApplicationUplinks(ctx, ttnpb.NewNsAsClient(conn), ups...); err != nil {
log.FromContext(ctx).WithError(err).Warn("Failed to send application uplinks to Application Server")
if nonRetryableUplinkError(err) {
log.FromContext(ctx).Warn("Error is non-retryable, dropping application uplinks")
if !retryableUplinkError(err) {
return
}
ns.enqueueApplicationUplinks(ctx, ups...)
Expand Down Expand Up @@ -471,12 +466,10 @@ var (
}
)

func nonRetryableUplinkError(err error) bool {
return errors.IsFailedPrecondition(err) ||
func retryableUplinkError(err error) bool {
return errors.IsCanceled(err) ||
errors.IsDeadlineExceeded(err) ||
errors.IsResourceExhausted(err) ||
errors.IsAborted(err) ||
errors.IsUnauthenticated(err) ||
errors.IsPermissionDenied(err) ||
errors.IsUnimplemented(err) ||
errors.IsInternal(err)
errors.IsUnavailable(err)
}

0 comments on commit 520de4c

Please sign in to comment.