fix: add retry policy to grpc calls.
Some error codes are not on the stream, eg. istio is sending some special ones, and we already used to implement the same logic in java to bypass this issue. Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
This commit is contained in:
parent
d0ec36feb1
commit
ae7f066bd3
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
|
@ -80,6 +81,44 @@ class GrpcResolver:
|
|||
("grpc.initial_reconnect_backoff_ms", config.retry_backoff_ms),
|
||||
("grpc.max_reconnect_backoff_ms", config.retry_backoff_max_ms),
|
||||
("grpc.min_reconnect_backoff_ms", config.deadline_ms),
|
||||
(
|
||||
"grpc.service_config",
|
||||
json.dumps(
|
||||
{
|
||||
"methodConfig": [
|
||||
{
|
||||
"name": [
|
||||
{"service": "flagd.sync.v1.FlagSyncService"},
|
||||
{"service": "flagd.evaluation.v1.Service"},
|
||||
],
|
||||
"retryPolicy": {
|
||||
"maxAttempts": 3,
|
||||
"initialBackoff": "1s",
|
||||
"maxBackoff": "5s",
|
||||
"backoffMultiplier": 2.0,
|
||||
"retryableStatusCodes": [
|
||||
"CANCELLED",
|
||||
"UNKNOWN",
|
||||
"INVALID_ARGUMENT",
|
||||
"NOT_FOUND",
|
||||
"ALREADY_EXISTS",
|
||||
"PERMISSION_DENIED",
|
||||
"RESOURCE_EXHAUSTED",
|
||||
"FAILED_PRECONDITION",
|
||||
"ABORTED",
|
||||
"OUT_OF_RANGE",
|
||||
"UNIMPLEMENTED",
|
||||
"INTERNAL",
|
||||
"UNAVAILABLE",
|
||||
"DATA_LOSS",
|
||||
"UNAUTHENTICATED",
|
||||
],
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
),
|
||||
]
|
||||
if config.tls:
|
||||
channel_args = {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,44 @@ class GrpcWatcher(FlagStateConnector):
|
|||
("grpc.initial_reconnect_backoff_ms", config.retry_backoff_ms),
|
||||
("grpc.max_reconnect_backoff_ms", config.retry_backoff_max_ms),
|
||||
("grpc.min_reconnect_backoff_ms", config.stream_deadline_ms),
|
||||
(
|
||||
"grpc.service_config",
|
||||
json.dumps(
|
||||
{
|
||||
"methodConfig": [
|
||||
{
|
||||
"name": [
|
||||
{"service": "flagd.sync.v1.FlagSyncService"},
|
||||
{"service": "flagd.evaluation.v1.Service"},
|
||||
],
|
||||
"retryPolicy": {
|
||||
"maxAttempts": 3,
|
||||
"initialBackoff": "1s",
|
||||
"maxBackoff": "5s",
|
||||
"backoffMultiplier": 2.0,
|
||||
"retryableStatusCodes": [
|
||||
"CANCELLED",
|
||||
"UNKNOWN",
|
||||
"INVALID_ARGUMENT",
|
||||
"NOT_FOUND",
|
||||
"ALREADY_EXISTS",
|
||||
"PERMISSION_DENIED",
|
||||
"RESOURCE_EXHAUSTED",
|
||||
"FAILED_PRECONDITION",
|
||||
"ABORTED",
|
||||
"OUT_OF_RANGE",
|
||||
"UNIMPLEMENTED",
|
||||
"INTERNAL",
|
||||
"UNAVAILABLE",
|
||||
"DATA_LOSS",
|
||||
"UNAUTHENTICATED",
|
||||
],
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
),
|
||||
]
|
||||
if config.default_authority is not None:
|
||||
options.append(("grpc.default_authority", config.default_authority))
|
||||
|
|
|
|||
Loading…
Reference in New Issue