Skip to content

Commit bd7c978

Browse files
authored
datasource: retry policy for remote data source (envoyproxy#9463)
Implement a retry policy for remote data sources. Risk Level: Low Testing: Unit test Docs Changes: N/A Release Notes: added Fixes: envoyproxy#9438 Signed-off-by: Yan Xue <[email protected]>
1 parent 841ad99 commit bd7c978

File tree

16 files changed

+520
-224
lines changed

16 files changed

+520
-224
lines changed

api/envoy/api/v2/core/backoff.proto

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
syntax = "proto3";
2+
3+
package envoy.api.v2.core;
4+
5+
import "google/protobuf/duration.proto";
6+
7+
import "udpa/annotations/migrate.proto";
8+
import "validate/validate.proto";
9+
10+
option java_package = "io.envoyproxy.envoy.api.v2.core";
11+
option java_outer_classname = "BackoffProto";
12+
option java_multiple_files = true;
13+
option (udpa.annotations.file_migrate).move_to_package = "envoy.config.core.v3";
14+
15+
// [#protodoc-title: Backoff Strategy]
16+
17+
// Configuration defining a jittered exponential back off strategy.
18+
message BackoffStrategy {
19+
// The base interval to be used for the next back off computation. It should
20+
// be greater than zero and less than or equal to :ref:`max_interval
21+
// <envoy_api_field_core.BackoffStrategy.max_interval>`.
22+
google.protobuf.Duration base_interval = 1 [(validate.rules).duration = {
23+
required: true
24+
gte {nanos: 1000000}
25+
}];
26+
27+
// Specifies the maximum interval between retries. This parameter is optional,
28+
// but must be greater than or equal to the :ref:`base_interval
29+
// <envoy_api_field_core.BackoffStrategy.base_interval>` if set. The default
30+
// is 10 times the :ref:`base_interval
31+
// <envoy_api_field_core.BackoffStrategy.base_interval>`.
32+
google.protobuf.Duration max_interval = 2 [(validate.rules).duration = {gt {}}];
33+
}

api/envoy/api/v2/core/base.proto

+17
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ syntax = "proto3";
22

33
package envoy.api.v2.core;
44

5+
import "envoy/api/v2/core/backoff.proto";
56
import "envoy/api/v2/core/http_uri.proto";
67
import "envoy/type/percent.proto";
78
import "envoy/type/semantic_version.proto";
89

910
import "google/protobuf/any.proto";
11+
import "google/protobuf/duration.proto";
1012
import "google/protobuf/struct.proto";
1113
import "google/protobuf/wrappers.proto";
1214

@@ -277,13 +279,28 @@ message DataSource {
277279
}
278280
}
279281

282+
// The message specifies the retry policy of remote data source when fetching fails.
283+
message RetryPolicy {
284+
// Specifies parameters that control :ref:`retry backoff strategy <envoy_api_msg_core.BackoffStrategy>`.
285+
// This parameter is optional, in which case the default base interval is 1000 milliseconds. The
286+
// default maximum interval is 10 times the base interval.
287+
BackoffStrategy retry_back_off = 1;
288+
289+
// Specifies the allowed number of retries. This parameter is optional and
290+
// defaults to 1.
291+
google.protobuf.UInt32Value num_retries = 2;
292+
}
293+
280294
// The message specifies how to fetch data from remote and how to verify it.
281295
message RemoteDataSource {
282296
// The HTTP URI to fetch the remote data.
283297
HttpUri http_uri = 1 [(validate.rules).message = {required: true}];
284298

285299
// SHA256 string for verifying data.
286300
string sha256 = 2 [(validate.rules).string = {min_bytes: 1}];
301+
302+
// Retry policy for fetching remote data.
303+
RetryPolicy retry_policy = 3;
287304
}
288305

289306
// Async data source which support async data fetch.
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
syntax = "proto3";
2+
3+
package envoy.config.core.v3;
4+
5+
import "google/protobuf/duration.proto";
6+
7+
import "udpa/annotations/versioning.proto";
8+
9+
import "validate/validate.proto";
10+
11+
option java_package = "io.envoyproxy.envoy.config.core.v3";
12+
option java_outer_classname = "BackoffProto";
13+
option java_multiple_files = true;
14+
15+
// [#protodoc-title: Backoff Strategy]
16+
17+
// Configuration defining a jittered exponential back off strategy.
18+
message BackoffStrategy {
19+
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.BackoffStrategy";
20+
21+
// The base interval to be used for the next back off computation. It should
22+
// be greater than zero and less than or equal to :ref:`max_interval
23+
// <envoy_api_field_config.core.v3.BackoffStrategy.max_interval>`.
24+
google.protobuf.Duration base_interval = 1 [(validate.rules).duration = {
25+
required: true
26+
gte {nanos: 1000000}
27+
}];
28+
29+
// Specifies the maximum interval between retries. This parameter is optional,
30+
// but must be greater than or equal to the :ref:`base_interval
31+
// <envoy_api_field_config.core.v3.BackoffStrategy.base_interval>` if set. The default
32+
// is 10 times the :ref:`base_interval
33+
// <envoy_api_field_config.core.v3.BackoffStrategy.base_interval>`.
34+
google.protobuf.Duration max_interval = 2 [(validate.rules).duration = {gt {}}];
35+
}

api/envoy/config/core/v3/base.proto

+19
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ syntax = "proto3";
22

33
package envoy.config.core.v3;
44

5+
import "envoy/config/core/v3/backoff.proto";
56
import "envoy/config/core/v3/http_uri.proto";
67
import "envoy/type/v3/percent.proto";
78
import "envoy/type/v3/semantic_version.proto";
89

910
import "google/protobuf/any.proto";
11+
import "google/protobuf/duration.proto";
1012
import "google/protobuf/struct.proto";
1113
import "google/protobuf/wrappers.proto";
1214

@@ -299,6 +301,20 @@ message DataSource {
299301
}
300302
}
301303

304+
// The message specifies the retry policy of remote data source when fetching fails.
305+
message RetryPolicy {
306+
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.RetryPolicy";
307+
308+
// Specifies parameters that control :ref:`retry backoff strategy <envoy_api_msg_config.core.v3.BackoffStrategy>`.
309+
// This parameter is optional, in which case the default base interval is 1000 milliseconds. The
310+
// default maximum interval is 10 times the base interval.
311+
BackoffStrategy retry_back_off = 1;
312+
313+
// Specifies the allowed number of retries. This parameter is optional and
314+
// defaults to 1.
315+
google.protobuf.UInt32Value num_retries = 2;
316+
}
317+
302318
// The message specifies how to fetch data from remote and how to verify it.
303319
message RemoteDataSource {
304320
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.RemoteDataSource";
@@ -308,6 +324,9 @@ message RemoteDataSource {
308324

309325
// SHA256 string for verifying data.
310326
string sha256 = 2 [(validate.rules).string = {min_bytes: 1}];
327+
328+
// Retry policy for fetching remote data.
329+
RetryPolicy retry_policy = 3;
311330
}
312331

313332
// Async data source which support async data fetch.

docs/root/api-v2/common_messages/common_messages.rst

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Common messages
77

88
../api/v2/core/base.proto
99
../api/v2/core/address.proto
10+
../api/v2/core/backoff.proto
1011
../api/v2/core/protocol.proto
1112
../api/v2/discovery.proto
1213
../api/v2/core/config_source.proto

docs/root/api-v3/common_messages/common_messages.rst

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Common messages
77

88
../config/core/v3/base.proto
99
../config/core/v3/address.proto
10+
../config/core/v3/backoff.proto
1011
../config/core/v3/protocol.proto
1112
../service/discovery/v3/discovery.proto
1213
../config/core/v3/config_source.proto

docs/root/intro/version_history.rst

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Version history
1010
* admin: added support for displaying ip address subject alternate names in :ref:`certs<operations_admin_interface_certs>` end point.
1111
* buffer: force copy when appending small slices to OwnedImpl buffer to avoid fragmentation.
1212
* config: use type URL to select an extension whenever the config type URL (or its previous versions) uniquely identify a typed extension, see :ref:`extension configuration <config_overview_extension_configuration>`.
13+
* datasource: added retry policy for remote async data source.
1314
* dns: the STRICT_DNS cluster now only resolves to 0 hosts if DNS resolution successfully returns 0 hosts.
1415
* dns: added support for :ref:`dns_failure_refresh_rate <envoy_api_field_config.common.dynamic_forward_proxy.v2alpha.DnsCacheConfig.dns_failure_refresh_rate>` for the :ref:`dns cache <envoy_api_msg_config.common.dynamic_forward_proxy.v2alpha.DnsCacheConfig>` to set the DNS refresh rate during failures.
1516
* http filters: http filter extensions use the "envoy.filters.http" name space. A mapping

generated_api_shadow/envoy/api/v2/core/backoff.proto

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated_api_shadow/envoy/api/v2/core/base.proto

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated_api_shadow/envoy/config/core/v3/backoff.proto

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated_api_shadow/envoy/config/core/v3/base.proto

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/common/config/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ envoy_cc_library(
5252
"//include/envoy/api:api_interface",
5353
"//include/envoy/init:manager_interface",
5454
"//include/envoy/upstream:cluster_manager_interface",
55+
"//source/common/common:backoff_lib",
5556
"//source/common/common:empty_string",
5657
"//source/common/init:target_lib",
5758
"//source/common/protobuf:utility_lib",

0 commit comments

Comments
 (0)