Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…eway into timeouts
  • Loading branch information
yaelSchechter committed Feb 21, 2024
2 parents 366d4bf + 501b262 commit f46ea5a
Show file tree
Hide file tree
Showing 68 changed files with 561 additions and 726 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- uses: ./tools/github-actions/setup-deps

- name: Download EG Binaries
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: envoy-gateway
path: bin/
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
- uses: ./tools/github-actions/setup-deps

- name: Download EG Binaries
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: envoy-gateway
path: bin/
Expand All @@ -139,7 +139,7 @@ jobs:
- uses: ./tools/github-actions/setup-deps

- name: Download EG Binaries
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
with:
name: envoy-gateway
path: bin/
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
- uses: ./tools/github-actions/setup-deps

- name: Initialize CodeQL
uses: github/codeql-action/init@e8893c57a1f3a2b659b6b55564fdfdbbd2982911 # v3.24.0
uses: github/codeql-action/init@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@e8893c57a1f3a2b659b6b55564fdfdbbd2982911 # v3.24.0
uses: github/codeql-action/autobuild@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e8893c57a1f3a2b659b6b55564fdfdbbd2982911 # v3.24.0
uses: github/codeql-action/analyze@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ jobs:
retention-days: 5

- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@e8893c57a1f3a2b659b6b55564fdfdbbd2982911 # v3.24.0
uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
with:
sarif_file: results.sarif
5 changes: 5 additions & 0 deletions api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ type BackendTrafficPolicySpec struct {
// +optional
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"`

// Retry provides more advanced usage, allowing users to customize the number of retries, retry fallback strategy, and retry triggering conditions.
// If not set, retry will be disabled.
// +optional
Retry *Retry `json:"retry,omitempty"`

// Timeout settings for the backend connections.
//
// +optional
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha1/healthcheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ type TCPActiveHealthChecker struct {
Receive *ActiveHealthCheckPayload `json:"receive,omitempty" yaml:"receive,omitempty"`
}

// HTTPStatus defines the http status code.
// +kubebuilder:validation:Minimum=100
// +kubebuilder:validation:Maximum=600
// +kubebuilder:validation:ExclusiveMaximum=true
type HTTPStatus int

// ActiveHealthCheckPayloadType is the type of the payload.
// +kubebuilder:validation:Enum=Text;Binary
type ActiveHealthCheckPayloadType string
Expand Down
111 changes: 111 additions & 0 deletions api/v1alpha1/retry_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Retry defines the retry strategy to be applied.
type Retry struct {
// NumRetries is the number of retries to be attempted. Defaults to 2.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=2
NumRetries *int32 `json:"numRetries,omitempty"`

// RetryOn specifies the retry trigger condition.
//
// If not specified, the default is to retry on connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes(503).
// +optional
RetryOn *RetryOn `json:"retryOn,omitempty"`

// PerRetry is the retry policy to be applied per retry attempt.
//
// +optional
PerRetry *PerRetryPolicy `json:"perRetry,omitempty"`
}

type RetryOn struct {
// Triggers specifies the retry trigger condition(Http/Grpc).
//
// +optional
Triggers []TriggerEnum `json:"triggers,omitempty"`

// HttpStatusCodes specifies the http status codes to be retried.
//
// +optional
HTTPStatusCodes []HTTPStatus `json:"httpStatusCodes,omitempty"`
}

// TriggerEnum specifies the conditions that trigger retries.
// +kubebuilder:validation:Enum={"5xx","gateway-error","disconnect-reset","connect-failure","retriable-4xx","refused-stream","retriable-status-codes","cancelled","deadline-exceeded","internal","resource-exhausted","unavailable"}
type TriggerEnum string

const (
// HTTP events.
// For additional details, see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-on

// 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.
Error5XX TriggerEnum = "5xx"
// The response is a gateway error (502,503 or 504).
GatewayError TriggerEnum = "gateway-error"
// The upstream server does not respond at all (disconnect/reset/read timeout.)
DisconnectRest TriggerEnum = "disconnect-reset"
// Connection failure to the upstream server (connect timeout, etc.). (Included in *5xx*)
ConnectFailure TriggerEnum = "connect-failure"
// The upstream server responds with a retriable 4xx response code.
// Currently, the only response code in this category is 409.
Retriable4XX TriggerEnum = "retriable-4xx"
// The upstream server resets the stream with a REFUSED_STREAM error code.
RefusedStream TriggerEnum = "refused-stream"
// The upstream server responds with any response code matching one defined in the RetriableStatusCodes.
RetriableStatusCodes TriggerEnum = "retriable-status-codes"

// GRPC events, currently only supported for gRPC status codes in response headers.
// For additional details, see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-grpc-on

// The gRPC status code in the response headers is “cancelled”.
Cancelled TriggerEnum = "cancelled"
// The gRPC status code in the response headers is “deadline-exceeded”.
DeadlineExceeded TriggerEnum = "deadline-exceeded"
// The gRPC status code in the response headers is “internal”.
Internal TriggerEnum = "internal"
// The gRPC status code in the response headers is “resource-exhausted”.
ResourceExhausted TriggerEnum = "resource-exhausted"
// The gRPC status code in the response headers is “unavailable”.
Unavailable TriggerEnum = "unavailable"
)

type PerRetryPolicy struct {
// Timeout is the timeout per retry attempt.
//
// +optional
// +kubebuilder:validation:Format=duration
Timeout *metav1.Duration `json:"timeout,omitempty"`
// Backoff is the backoff policy to be applied per retry attempt. gateway uses a fully jittered exponential
// back-off algorithm for retries. For additional details,
// see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#config-http-filters-router-x-envoy-max-retries
//
// +optional
BackOff *BackOffPolicy `json:"backOff,omitempty"`
}

type BackOffPolicy struct {
// BaseInterval is the base interval between retries.
//
// +kubebuilder:validation:Format=duration
BaseInterval *metav1.Duration `json:"baseInterval,omitempty"`
// MaxInterval is the maximum interval between retries. This parameter is optional, but must be greater than or equal to the base_interval if set.
// The default is 10 times the base_interval
//
// +optional
// +kubebuilder:validation:Format=duration
MaxInterval *metav1.Duration `json:"maxInterval,omitempty"`
// we can add rate limited based backoff config here if we want to.
}
8 changes: 7 additions & 1 deletion api/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
// DefaultDeploymentMemoryResourceRequests for deployment memory resource
DefaultDeploymentMemoryResourceRequests = "512Mi"
// DefaultEnvoyProxyImage is the default image used by envoyproxy
DefaultEnvoyProxyImage = "envoyproxy/envoy-dev:latest"
DefaultEnvoyProxyImage = "envoyproxy/envoy:distroless-dev"
// DefaultRateLimitImage is the default image used by ratelimit.
DefaultRateLimitImage = "envoyproxy/ratelimit:master"
// HTTPProtocol is the common-used http protocol.
Expand Down Expand Up @@ -364,3 +364,9 @@ type KubernetesHorizontalPodAutoscalerSpec struct {
// +optional
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty"`
}

// HTTPStatus defines the http status code.
// +kubebuilder:validation:Minimum=100
// +kubebuilder:validation:Maximum=600
// +kubebuilder:validation:ExclusiveMaximum=true
type HTTPStatus int
110 changes: 110 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.

Loading

0 comments on commit f46ea5a

Please sign in to comment.