Skip to content

Commit

Permalink
API: support max_retries in circuit breakers API (#2773)
Browse files Browse the repository at this point in the history
* support max_retries in circuit breakers API, remove retry_budget defaults

Signed-off-by: Guy Daich <[email protected]>

* add manifests

Signed-off-by: Guy Daich <[email protected]>

* remove CBs if not defined

Signed-off-by: Guy Daich <[email protected]>

* fix cov, lint and json

Signed-off-by: Guy Daich <[email protected]>

* enforce 1024 retry limit in xds translator

Signed-off-by: Guy Daich <[email protected]>

---------

Signed-off-by: Guy Daich <[email protected]>
  • Loading branch information
guydc authored Mar 5, 2024
1 parent 9b48ff9 commit dd60e40
Show file tree
Hide file tree
Showing 96 changed files with 341 additions and 527 deletions.
8 changes: 8 additions & 0 deletions api/v1alpha1/circuitbreaker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ type CircuitBreaker struct {
// +optional
MaxParallelRequests *int64 `json:"maxParallelRequests,omitempty"`

// The maximum number of parallel retries that Envoy will make to the referenced backend defined within a xRoute rule.
//
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=4294967295
// +kubebuilder:default=1024
// +optional
MaxParallelRetries *int64 `json:"maxParallelRetries,omitempty"`

// The maximum number of requests that Envoy will make over a single connection to the referenced backend defined within a xRoute rule.
// Default: unlimited.
//
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ spec:
maximum: 4294967295
minimum: 0
type: integer
maxParallelRetries:
default: 1024
description: The maximum number of parallel retries that Envoy
will make to the referenced backend defined within a xRoute
rule.
format: int64
maximum: 4294967295
minimum: 0
type: integer
maxPendingRequests:
default: 1024
description: The maximum number of pending requests that Envoy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -697,9 +695,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -723,9 +719,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -744,9 +738,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -765,9 +757,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down Expand Up @@ -406,11 +402,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down Expand Up @@ -447,11 +439,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down Expand Up @@ -480,11 +468,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down Expand Up @@ -513,11 +497,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -223,9 +221,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -249,9 +245,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -270,9 +264,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -291,9 +283,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -27,9 +25,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -53,9 +49,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -74,9 +68,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -95,9 +87,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down Expand Up @@ -298,11 +294,7 @@
"circuitBreakers": {
"thresholds": [
{
"retryBudget": {
"budgetPercent": {
"value": 100
}
}
"maxRetries": 1024
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -167,9 +165,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand All @@ -27,9 +25,7 @@ xds:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
circuitBreakers:
thresholds:
- retryBudget:
budgetPercent:
value: 100
- maxRetries: 1024
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 10s
Expand Down
10 changes: 10 additions & 0 deletions internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,15 @@ func (t *Translator) buildCircuitBreaker(policy *egv1a1.BackendTrafficPolicy) *i
}
}

if pcb.MaxParallelRetries != nil {
if ui32, ok := int64ToUint32(*pcb.MaxParallelRetries); ok {
cb.MaxParallelRetries = &ui32
} else {
setBackendTrafficPolicyTranslationErrorCondition(policy, "Circuit Breaker", fmt.Sprintf("invalid MaxParallelRetries value %d", *pcb.MaxParallelRetries))
return nil
}
}

if pcb.MaxRequestsPerConnection != nil {
if ui32, ok := int64ToUint32(*pcb.MaxRequestsPerConnection); ok {
cb.MaxRequestsPerConnection = &ui32
Expand All @@ -927,6 +936,7 @@ func (t *Translator) buildCircuitBreaker(policy *egv1a1.BackendTrafficPolicy) *i
return nil
}
}

}

return cb
Expand Down
Loading

0 comments on commit dd60e40

Please sign in to comment.