VOL-5106 interadaptor grpc request retry
Change-Id: I0b0383496e8913ca451587522d8df077f402f346
diff --git a/VERSION b/VERSION
index 7075368..cca25a9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.4.0-dev
+4.4.1
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 3eb3a08..3f77346 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -46,6 +46,7 @@
plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
"github.com/opencord/voltha-lib-go/v7/pkg/pmmetrics"
+ grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
conf "github.com/opencord/voltha-openolt-adapter/internal/pkg/config"
"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
@@ -58,7 +59,7 @@
oop "github.com/opencord/voltha-protos/v5/go/openolt"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc"
- "google.golang.org/grpc/codes"
+ codes "google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -3978,8 +3979,14 @@
logger.Errorw(ctx, "grpc-client-not-created", log.Fields{"error": err, "endpoint": endpoint})
return err
}
- go dh.childAdapterClients[endpoint].Start(log.WithSpanFromContext(context.TODO(), ctx), dh.getOnuInterAdapterServiceClientHandler)
+ retryCodes := []codes.Code{
+ codes.Unavailable, // server is currently unavailable
+ codes.DeadlineExceeded, // deadline for the operation was exceeded
+ }
+ backoffCtxOption := grpc_retry.WithBackoff(grpc_retry.BackoffLinearWithJitter(dh.cfg.PerRPCRetryTimeout, 0.2))
+ grpcRetryOptions := grpc_retry.UnaryClientInterceptor(grpc_retry.WithMax(dh.cfg.MaxRetries), grpc_retry.WithPerRetryTimeout(dh.cfg.PerRPCRetryTimeout), grpc_retry.WithCodes(retryCodes...), backoffCtxOption)
+ go dh.childAdapterClients[endpoint].Start(log.WithSpanFromContext(context.TODO(), ctx), dh.getOnuInterAdapterServiceClientHandler, grpcRetryOptions)
// Wait until we have a connection to the child adapter.
// Unlimited retries or until context expires
subCtx := log.WithSpanFromContext(context.TODO(), ctx)