adding retryon support

Signed-off-by: brandoncate <brandon.cate@shipt.com>
This commit is contained in:
brandoncate
2022-04-08 09:58:23 -05:00
parent c68998d75e
commit 48cc7995d7
5 changed files with 102 additions and 1 deletions
+26
View File
@@ -255,6 +255,10 @@ type TimeoutPolicy struct {
Idle string `json:"idle,omitempty"`
}
// RetryOn is a string type alias with validation to ensure that the value is valid.
// +kubebuilder:validation:Enum="5xx";gateway-error;reset;connect-failure;retriable-4xx;refused-stream;retriable-status-codes;retriable-headers;cancelled;deadline-exceeded;internal;resource-exhausted;unavailable
type RetryOn string
// RetryPolicy defines the attributes associated with retrying policy.
type RetryPolicy struct {
// NumRetries is maximum allowed number of retries.
@@ -264,6 +268,28 @@ type RetryPolicy struct {
// PerTryTimeout specifies the timeout per retry attempt.
// Ignored if NumRetries is not supplied.
PerTryTimeout string `json:"perTryTimeout,omitempty"`
// RetryOn specifies the conditions on which to retry a request.
//
// Supported [HTTP conditions](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-on):
//
// - `5xx`
// - `gateway-error`
// - `reset`
// - `connect-failure`
// - `retriable-4xx`
// - `refused-stream`
// - `retriable-status-codes`
// - `retriable-headers`
//
// Supported [gRPC conditions](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/router_filter#x-envoy-retry-grpc-on):
//
// - `cancelled`
// - `deadline-exceeded`
// - `internal`
// - `resource-exhausted`
// - `unavailable`
// +optional
RetryOn []RetryOn `json:"retryOn,omitempty"`
}
// ReplacePrefix describes a path prefix replacement.
@@ -300,6 +300,11 @@ func (in *ReplacePrefix) DeepCopy() *ReplacePrefix {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RetryPolicy) DeepCopyInto(out *RetryPolicy) {
*out = *in
if in.RetryOn != nil {
in, out := &in.RetryOn, &out.RetryOn
*out = make([]RetryOn, len(*in))
copy(*out, *in)
}
return
}
@@ -338,7 +343,7 @@ func (in *Route) DeepCopyInto(out *Route) {
if in.RetryPolicy != nil {
in, out := &in.RetryPolicy, &out.RetryPolicy
*out = new(RetryPolicy)
**out = **in
(*in).DeepCopyInto(*out)
}
if in.HealthCheckPolicy != nil {
in, out := &in.HealthCheckPolicy, &out.HealthCheckPolicy
+12
View File
@@ -19,6 +19,7 @@ package router
import (
"context"
"fmt"
"strings"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
@@ -444,11 +445,22 @@ func (cr *ContourRouter) makeRetryPolicy(canary *flaggerv1.Canary) *contourv1.Re
return &contourv1.RetryPolicy{
NumRetries: uint32(canary.Spec.Service.Retries.Attempts),
PerTryTimeout: canary.Spec.Service.Retries.PerTryTimeout,
RetryOn: makeRetryOn(canary.Spec.Service.Retries.RetryOn),
}
}
return nil
}
func makeRetryOn(retryOnString string) []contourv1.RetryOn {
retryOnSplit := strings.Split(retryOnString, ",")
retryOn := make([]contourv1.RetryOn, len(retryOnSplit))
for i, v := range retryOnSplit {
retryOn[i] = contourv1.RetryOn(v)
}
return retryOn
}
func (cr *ContourRouter) makeLinkerdHeaderValue(canary *flaggerv1.Canary, serviceName string) contourv1.HeaderValue {
return contourv1.HeaderValue{
Name: "l5d-dst-override",
+1
View File
@@ -132,6 +132,7 @@ func newTestCanary() *flaggerv1.Canary {
Retries: &istiov1alpha3.HTTPRetry{
Attempts: 10,
PerTryTimeout: "30s",
RetryOn: "connect-failure,gateway-error",
},
Gateways: []string{
"public-gateway.istio",
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
cat <<EOF | kubectl apply -f -
apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
name: podinfo
namespace: test
spec:
provider: contour
targetRef:
apiVersion: apps/v1
kind: Deployment
name: podinfo
progressDeadlineSeconds: 60
service:
port: 80
targetPort: 9898
retries:
attempts: 3
perTryTimeout: 5s
retryOn: connect-failure,5xx
analysis:
interval: 15s
threshold: 15
maxWeight: 50
stepWeight: 10
metrics:
- name: request-success-rate
threshold: 99
interval: 1m
- name: request-duration
threshold: 500
interval: 1m
webhooks:
- name: acceptance-test
type: pre-rollout
url: http://flagger-loadtester.test/
timeout: 10s
metadata:
type: bash
cmd: "curl -sd 'test' http://podinfo-canary/token | grep token"
- name: contour-acceptance-test
type: pre-rollout
url: http://flagger-loadtester.test/
timeout: 10s
metadata:
type: bash
cmd: "curl -sd 'test' -H 'Host: app.example.com' http://envoy.projectcontour/token | grep token"
- name: load-test
url: http://flagger-loadtester.test/
timeout: 5s
metadata:
type: cmd
cmd: "hey -z 1m -q 5 -c 2 -host app.example.com http://envoy.projectcontour"
logCmdOutput: "true"
EOF