(VOL-4953)enabling retry codes in open-olt-adaptor
Enabling retry codes in open-olt-adaptor grpc-client so that it retries the grpc requests to the voltha-core
in case the core is unavailable or the request times out
(retry for pipeline)
Change-Id: Iae93e445ed6363b5fd654bdc1cbe3e53778b2a67
diff --git a/cmd/openolt-adapter/main.go b/cmd/openolt-adapter/main.go
index 7d8cfe8..9e8e9e5 100644
--- a/cmd/openolt-adapter/main.go
+++ b/cmd/openolt-adapter/main.go
@@ -21,6 +21,8 @@
"context"
"errors"
"fmt"
+ grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
+ codes "google.golang.org/grpc/codes"
"os"
"os/signal"
"syscall"
@@ -137,7 +139,13 @@
logger.Fatal(ctx, "grpc-client-not-created")
}
// Start the core grpc client
- go a.coreClient.Start(ctx, getCoreServiceClientHandler)
+ retryCodes := []codes.Code{
+ codes.Unavailable, // server is currently unavailable
+ codes.DeadlineExceeded, // deadline for the operation was exceeded
+ }
+ grpcRetryOptions := grpc_retry.UnaryClientInterceptor(grpc_retry.WithMax(a.config.MaxRetries), grpc_retry.WithPerRetryTimeout(a.config.PerRPCRetryTimeout), grpc_retry.WithCodes(retryCodes...))
+ logger.Debug(ctx, "Configuration values", log.Fields{"RETRY": a.config.MaxRetries, "TIMEOUT": a.config.PerRPCRetryTimeout})
+ go a.coreClient.Start(ctx, getCoreServiceClientHandler, grpcRetryOptions)
// Create the open OLT adapter
if a.oltAdapter, err = a.startOpenOLT(ctx, a.coreClient, a.eventProxy, a.config, cm); err != nil {