Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Port: "retryOn" configuration on ServiceRouter CRD into release/1.1.x #3323

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3308.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
crd: adds the [`retryOn`](https://developer.hashicorp.com/consul/docs/connect/config-entries/service-router#routes-destination-retryon) field to the ServiceRouter CRD.
```
7 changes: 7 additions & 0 deletions charts/consul/templates/crd-servicerouters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ spec:
any existing header values of the same name.
type: object
type: object
retryOn:
description: RetryOn is a flat list of conditions for Consul
to retry requests based on the response from an upstream
service.
items:
type: string
type: array
retryOnConnectFailure:
description: RetryOnConnectFailure allows for connection
failure errors to trigger a retry.
Expand Down
4 changes: 4 additions & 0 deletions control-plane/api/v1alpha1/servicerouter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ type ServiceRouteDestination struct {
NumRetries uint32 `json:"numRetries,omitempty"`
// RetryOnConnectFailure allows for connection failure errors to trigger a retry.
RetryOnConnectFailure bool `json:"retryOnConnectFailure,omitempty"`
// RetryOn is a flat list of conditions for Consul to retry requests based on the response from an upstream service.
// Refer to the valid conditions here: https://developer.hashicorp.com/consul/docs/connect/config-entries/service-router#routes-destination-retryon
RetryOn []string `json:"retryOn,omitempty"`
// RetryOnStatusCodes is a flat list of http response status codes that are eligible for retry.
RetryOnStatusCodes []uint32 `json:"retryOnStatusCodes,omitempty"`
// Allow HTTP header manipulation to be configured.
Expand Down Expand Up @@ -352,6 +355,7 @@ func (in *ServiceRouteDestination) toConsul() *capi.ServiceRouteDestination {
RequestTimeout: in.RequestTimeout.Duration,
NumRetries: in.NumRetries,
RetryOnConnectFailure: in.RetryOnConnectFailure,
RetryOn: in.RetryOn,
RetryOnStatusCodes: in.RetryOnStatusCodes,
RequestHeaders: in.RequestHeaders.toConsul(),
ResponseHeaders: in.ResponseHeaders.toConsul(),
Expand Down
4 changes: 4 additions & 0 deletions control-plane/api/v1alpha1/servicerouter_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func TestServiceRouter_MatchesConsul(t *testing.T) {
RequestTimeout: metav1.Duration{Duration: 1 * time.Second},
NumRetries: 1,
RetryOnConnectFailure: true,
RetryOn: []string{"gateway-error"},
RetryOnStatusCodes: []uint32{500, 400},
RequestHeaders: &HTTPHeaderModifiers{
Add: map[string]string{
Expand Down Expand Up @@ -162,6 +163,7 @@ func TestServiceRouter_MatchesConsul(t *testing.T) {
RequestTimeout: 1 * time.Second,
NumRetries: 1,
RetryOnConnectFailure: true,
RetryOn: []string{"gateway-error"},
RetryOnStatusCodes: []uint32{500, 400},
RequestHeaders: &capi.HTTPHeaderModifiers{
Add: map[string]string{
Expand Down Expand Up @@ -288,6 +290,7 @@ func TestServiceRouter_ToConsul(t *testing.T) {
RequestTimeout: metav1.Duration{Duration: 1 * time.Second},
NumRetries: 1,
RetryOnConnectFailure: true,
RetryOn: []string{"gateway-error"},
RetryOnStatusCodes: []uint32{500, 400},
RequestHeaders: &HTTPHeaderModifiers{
Add: map[string]string{
Expand Down Expand Up @@ -365,6 +368,7 @@ func TestServiceRouter_ToConsul(t *testing.T) {
RequestTimeout: 1 * time.Second,
NumRetries: 1,
RetryOnConnectFailure: true,
RetryOn: []string{"gateway-error"},
RetryOnStatusCodes: []uint32{500, 400},
RequestHeaders: &capi.HTTPHeaderModifiers{
Add: map[string]string{
Expand Down
5 changes: 5 additions & 0 deletions control-plane/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 @@ -143,6 +143,13 @@ spec:
any existing header values of the same name.
type: object
type: object
retryOn:
description: RetryOn is a flat list of conditions for Consul
to retry requests based on the response from an upstream
service.
items:
type: string
type: array
retryOnConnectFailure:
description: RetryOnConnectFailure allows for connection
failure errors to trigger a retry.
Expand Down
Loading