Skip to content

Commit

Permalink
Add configuration CONFIG_GRPC_XDS_SERVER_CONNECT_RETRY_INTERVAL
Browse files Browse the repository at this point in the history
Signed-off-by: Renuka Fernando <[email protected]>
  • Loading branch information
renuka-fernando committed Dec 17, 2024
1 parent 6a2e826 commit a02d2ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,14 @@ The xDS client in the Rate limit service configure Rate limit service with the p
In case of connection failures, the xDS Client retries the connection to the xDS server with exponential backoff and the backoff parameters are configurable.

1. `XDS_CLIENT_BACKOFF_JITTER`: set to `"true"` to add jitter to the exponential backoff.
2. `XDS_CLIENT_BACKOFF_INITIAL_INTERVAL`: The base amount of time the xDS client waits before retyring the connection after failure. Default: "10s"
2. `XDS_CLIENT_BACKOFF_INITIAL_INTERVAL`: The base amount of time the xDS client waits before retrying the connection after failure. Default: "10s"
3. `XDS_CLIENT_BACKOFF_MAX_INTERVAL`: The max backoff interval is the upper limit on the amount of time the xDS client will wait between retries. After reaching the max backoff interval, the next retries will continue using the max interval. Default: "60s"
4. `XDS_CLIENT_BACKOFF_RANDOM_FACTOR`: This is a factor by which the initial interval is multiplied to calculate the next backoff interval. Default: "0.5"

The followings are the gRPC connection options.

1. `XDS_GRPC_CLIENT_OPTIONS_MAX_MSG_SIZE_IN_BYTES`: The maximum message size in bytes that the xDS client can receive and send.

For more information on xDS protocol please refer to the [envoy proxy documentation](https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol).

You can refer to [the sample xDS configuration management server](examples/xds-sotw-config-server/README.md).
Expand Down
17 changes: 14 additions & 3 deletions src/provider/xds_grpc_sotw_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,24 @@ func (p *XdsGrpcSotwProvider) watchConfigs() {
func (p *XdsGrpcSotwProvider) getGrpcConnection() (*grpc.ClientConn, error) {
backOff := grpc_retry.BackoffLinearWithJitter(p.settings.ConfigGrpcXdsServerConnectRetryInterval, 0.5)
logger.Infof("Dialing xDS Management Server: '%s'", p.settings.ConfigGrpcXdsServerUrl)
return grpc.Dial(
p.settings.ConfigGrpcXdsServerUrl,
grpcOptions := []grpc.DialOption{
p.getGrpcTransportCredentials(),
grpc.WithBlock(),
grpc.WithStreamInterceptor(
grpc_retry.StreamClientInterceptor(grpc_retry.WithBackoff(backOff)),
))
),
}
maxMsgSize := p.settings.XdsGrpcClientOptionsMaxMsgSizeInBytes
if maxMsgSize != 0 {
logger.Infof("Setting xDS gRPC max message size to %d bytes", maxMsgSize)
grpcOptions = append(grpcOptions,
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize),
grpc.MaxCallSendMsgSize(maxMsgSize)))
}
return grpc.Dial(
p.settings.ConfigGrpcXdsServerUrl,
grpcOptions...,
)
}

func (p *XdsGrpcSotwProvider) getGrpcTransportCredentials() grpc.DialOption {
Expand Down
3 changes: 3 additions & 0 deletions src/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ type Settings struct {
XdsClientBackoffRandomFactor float64 `envconfig:"XDS_CLIENT_BACKOFF_RANDOM_FACTOR" default:"0.5"`
XdsClientBackoffJitter bool `envconfig:"XDS_CLIENT_BACKOFF_JITTER" default:"true"`

// xDS gRPC client options
XdsGrpcClientOptionsMaxMsgSizeInBytes int `envconfig:"XDS_GRPC_CLIENT_OPTIONS_MAX_MSG_SIZE_IN_BYTES" default:""`

// Stats-related settings
UseDogStatsd bool `envconfig:"USE_DOG_STATSD" default:"false"`
UseDogStatsdMogrifiers []string `envconfig:"USE_DOG_STATSD_MOGRIFIERS" default:""`
Expand Down

0 comments on commit a02d2ca

Please sign in to comment.