Skip to content

Commit

Permalink
fix code
Browse files Browse the repository at this point in the history
Signed-off-by: zhaonan <[email protected]>
  • Loading branch information
zhaonan committed Nov 9, 2023
1 parent 0aa689c commit 19a388d
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 75 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type BackendTrafficPolicySpec struct {
// +optional
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`

// RetryStrategy allows the user to retry multiple times when a request fails.
// RetryStrategy allows the user to retry multiple times when a request fails.
// +optional
RetryStrategy *RetryStrategy `json:"retryStrategy,omitempty"`
}
Expand Down
28 changes: 14 additions & 14 deletions api/v1alpha1/retrystragegy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import (
// RetryStrategy defines the retry strategy to be applied.
//
// +kubebuilder:validation:XValidation:rule="self.type == 'Grpc' ? has(self.grpc) : !has(self.grpc)",message="If RetryStrategy type is Grpc, grpc field needs to be set."
// +kubebuilder:validation:XValidation:rule="self.type == 'Htttp' ? has(self.http) : !has(self.http)",message="If RetryStrategy type is Http, http field needs to be set."
// +kubebuilder:validation:XValidation:rule="self.type == 'Http' ? has(self.http) : !has(self.http)",message="If RetryStrategy type is Http, http field needs to be set."
type RetryStrategy struct {
// Type decides the type of RetryStrategy .
// Valid RetryStrategyType values are
// "Http",
// "Grpc",
//
Type RetryStrategyType `json:"type"`
// HttpRetry defines the retry triggering conditions for HTTP protocol.
// HTTPRetry defines the retry triggering conditions for HTTP protocol.
//
// +optional
Http *HttpRetry `json:"http,omitempty"`
HTTP *HTTPRetry `json:"http,omitempty"`
// GrpcRetry defines the retry triggering conditions for GRPC protocol.
//
// +optional
Expand All @@ -35,26 +35,26 @@ type RetryStrategy struct {
// PerRetry is the retry policy to be applied per retry attempt.
//
// +optional
PerRetry PerRetryPolicy `json:"perRetry,omitempty"`
PerRetry *PerRetryPolicy `json:"perRetry,omitempty"`
// RetryLimit is the retry limit policy to be applied.
//
// +optional
RetryLimit RetryLimitPolicy `json:"retryLimit,omitempty"`
RetryLimit *RetryLimitPolicy `json:"retryLimit,omitempty"`
}

// RetryStrategyType specifies the types of RetryStrategy.
// +kubebuilder:validation:Enum=Grpc;Http;
type RetryStrategyType string

const (
// HttpRetryStrategyType for http protocol.
HttpRetryStrategyType RetryStrategyType = "Http"
// HTTPRetryStrategyType for http protocol.
HTTPRetryStrategyType RetryStrategyType = "Http"
// GrpcRetryStrategyType for grpc protocol.
GrpcRetryStrategyType LoadBalancerType = "Grpc"
GrpcRetryStrategyType RetryStrategyType = "Grpc"
)

// HttpRetry defines the retry triggering conditions for HTTP protocol.
type HttpRetry struct {
// HTTPRetry defines the retry triggering conditions for HTTP protocol.
type HTTPRetry struct {
// RetryOn indicates the retry policy. One or more policies can be specified using a ',' delimited list.
// The supported policies are:
// * 5xx: gateway will attempt a retry if the upstream server responds with any 5xx response code, or does not respond at all (disconnect/reset/read timeout).
Expand Down Expand Up @@ -137,12 +137,12 @@ type RetryLimitPolicy struct {
// Static specifies a limit on concurrent retries.
//
// +optional
Static StaticPolicy `json:"static,omitempty"`
Static *StaticPolicy `json:"static,omitempty"`
// RetryBudget specifies a limit on concurrent retries in relation to the number of active requests. For additional details,
// see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/circuit_breaker.proto#envoy-v3-api-msg-config-cluster-v3-circuitbreakers-thresholds-retrybudget
//
// +optional
RetryBudget RetryBudgetPolicy `json:"retryBudget,omitempty"`
RetryBudget *RetryBudgetPolicy `json:"retryBudget,omitempty"`
}

// RetryLimitType specifies the types of RetryLimit.
Expand All @@ -151,9 +151,9 @@ type RetryLimitType string

const (
// StaticRetryStrategyType for static retry limit policy.
StaticRetryLimitType RetryLimitType = "Http"
StaticRetryLimitType RetryLimitType = "Static"
// RetryBudgetRetryStrategyType for retry budget limit policy.
RetryBudgetRetryLimitType RetryLimitType = "Grpc"
RetryBudgetRetryLimitType RetryLimitType = "RetryBudget"
)

type StaticPolicy struct {
Expand Down
70 changes: 43 additions & 27 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 @@ -246,7 +246,7 @@ spec:
type: string
type: object
http:
description: HttpRetry defines the retry triggering conditions
description: HTTPRetry defines the retry triggering conditions
for HTTP protocol.
properties:
retriableStatusCodes:
Expand Down Expand Up @@ -381,7 +381,7 @@ spec:
- message: If RetryStrategy type is Grpc, grpc field needs to be set.
rule: 'self.type == ''Grpc'' ? has(self.grpc) : !has(self.grpc)'
- message: If RetryStrategy type is Http, http field needs to be set.
rule: 'self.type == ''Htttp'' ? has(self.http) : !has(self.http)'
rule: 'self.type == ''Http'' ? has(self.http) : !has(self.http)'
targetRef:
description: targetRef is the name of the resource this policy is
being attached to. This Policy and the TargetRef MUST be in the
Expand Down
24 changes: 12 additions & 12 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -843,30 +843,30 @@ _Appears in:_
| `retryOn` _[RetryOn](#retryon)_ | GRPC retries are currently only supported for gRPC status codes in response headers. RetryOn indicates the retry policy. One or more policies can be specified using a ',' delimited list. The supported policies are: * cancelled: gateway will attempt a retry if the gRPC status code in the response headers is “cancelled”. * deadline-exceeded: gateway will attempt a retry if the gRPC status code in the response headers is “deadline-exceeded”. * internal: gateway will attempt a retry if the gRPC status code in the response headers is “internal”. * resource-exhausted: gateway will attempt a retry if the gRPC status code in the response headers is “resource-exhausted”. * unavailable: gateway will attempt a retry if the gRPC status code in the response headers is “unavailable”. For additional details, see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-grpc-on |


#### HeaderMatch
#### HTTPRetry



HeaderMatch defines the match attributes within the HTTP Headers of the request.
HTTPRetry defines the retry triggering conditions for HTTP protocol.

_Appears in:_
- [RateLimitSelectCondition](#ratelimitselectcondition)
- [RetryStrategy](#retrystrategy)

| Field | Description |
| --- | --- |
| `retryOn` _[RetryOn](#retryon)_ | RetryOn indicates the retry policy. One or more policies can be specified using a ',' delimited list. The supported policies are: * 5xx: gateway will attempt a retry if the upstream server responds with any 5xx response code, or does not respond at all (disconnect/reset/read timeout). (Includes connect-failure and refused-stream) * gateway-error: gateway will attempt a retry when the response is a gateway error (502,503 or 504). * reset: gateway will attempt a retry if the upstream server does not respond at all (disconnect/reset/read timeout.) * connect-failure: gateway will attempt a retry if a request is failed because of a connection failure to the upstream server (connect timeout, etc.). (Included in *5xx*) * retriable-4xx: gateway will attempt a retry if the upstream server responds with a retriable 4xx response code. Currently, the only response code in this category is 409. * refused-stream: gateway will attempt a retry if the upstream server resets the stream with a REFUSED_STREAM error code. This reset type indicates that a request is safe to retry. (Included in 5xx) * retriable-status-codes: gateway will attempt a retry if the upstream server responds with any response code matching one defined in the RetriableStatusCodes. For additional details, see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-on |
| `retriableStatusCodes` _integer array_ | HTTP status codes that should trigger a retry in addition to those specified by retry_on, required when retry_on is set to retriable-status-codes. |


#### HttpRetry
#### HeaderMatch



HttpRetry defines the retry triggering conditions for HTTP protocol.
HeaderMatch defines the match attributes within the HTTP Headers of the request.

_Appears in:_
- [RetryStrategy](#retrystrategy)
- [RateLimitSelectCondition](#ratelimitselectcondition)

| Field | Description |
| --- | --- |
| `retryOn` _[RetryOn](#retryon)_ | RetryOn indicates the retry policy. One or more policies can be specified using a ',' delimited list. The supported policies are: * 5xx: gateway will attempt a retry if the upstream server responds with any 5xx response code, or does not respond at all (disconnect/reset/read timeout). (Includes connect-failure and refused-stream) * gateway-error: gateway will attempt a retry when the response is a gateway error (502,503 or 504). * reset: gateway will attempt a retry if the upstream server does not respond at all (disconnect/reset/read timeout.) * connect-failure: gateway will attempt a retry if a request is failed because of a connection failure to the upstream server (connect timeout, etc.). (Included in *5xx*) * retriable-4xx: gateway will attempt a retry if the upstream server responds with a retriable 4xx response code. Currently, the only response code in this category is 409. * refused-stream: gateway will attempt a retry if the upstream server resets the stream with a REFUSED_STREAM error code. This reset type indicates that a request is safe to retry. (Included in 5xx) * retriable-status-codes: gateway will attempt a retry if the upstream server responds with any response code matching one defined in the RetriableStatusCodes. For additional details, see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-on |
| `retriableStatusCodes` _integer array_ | HTTP status codes that should trigger a retry in addition to those specified by retry_on, required when retry_on is set to retriable-status-codes. |


#### InfrastructureProviderType
Expand Down Expand Up @@ -1623,7 +1623,7 @@ _Underlying type:_ `string`

_Appears in:_
- [GrpcRetry](#grpcretry)
- [HttpRetry](#httpretry)
- [HTTPRetry](#httpretry)



Expand All @@ -1639,7 +1639,7 @@ _Appears in:_
| Field | Description |
| --- | --- |
| `type` _[RetryStrategyType](#retrystrategytype)_ | Type decides the type of RetryStrategy . Valid RetryStrategyType values are "Http", "Grpc", |
| `http` _[HttpRetry](#httpretry)_ | HttpRetry defines the retry triggering conditions for HTTP protocol. |
| `http` _[HTTPRetry](#httpretry)_ | HTTPRetry defines the retry triggering conditions for HTTP protocol. |
| `grpc` _[GrpcRetry](#grpcretry)_ | GrpcRetry defines the retry triggering conditions for GRPC protocol. |
| `numRetries` _integer_ | NumRetries is the number of retries to be attempted. Defaults to 1. |
| `perRetry` _[PerRetryPolicy](#perretrypolicy)_ | PerRetry is the retry policy to be applied per retry attempt. |
Expand Down
Loading

0 comments on commit 19a388d

Please sign in to comment.