Skip to content

Commit

Permalink
Backport of Adding support for idleTimeout in Service Router spec int…
Browse files Browse the repository at this point in the history
…o release/1.0.x (#2198)

* backport of commit b990087

* backport of commit fa3ca5f

* backport of commit 19f05a2

* backport of commit ceeb4b7

---------

Co-authored-by: Kaustubh Phatak <kaustubh.phatak@machinify.com>
  • Loading branch information
hc-github-team-consul-core and kphatak authored May 29, 2023
1 parent cd8d675 commit f888c3a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions charts/consul/templates/crd-servicerouters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ spec:
description: Destination controls how to proxy the matching
request(s) to a service.
properties:
idleTimeout:
description: IdleTimeout is total amount of time permitted
for the request stream to be idle.
type: string
namespace:
description: Namespace is the Consul namespace to resolve
the service from instead of the current namespace. If
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 @@ -137,6 +137,9 @@ type ServiceRouteDestination struct {
// This requires that either match.http.pathPrefix or match.http.pathExact
// be configured on this route.
PrefixRewrite string `json:"prefixRewrite,omitempty"`
// IdleTimeout is total amount of time permitted
// for the request stream to be idle.
IdleTimeout metav1.Duration `json:"idleTimeout,omitempty"`
// RequestTimeout is the total amount of time permitted for the entire
// downstream request (and retries) to be processed.
RequestTimeout metav1.Duration `json:"requestTimeout,omitempty"`
Expand Down Expand Up @@ -334,6 +337,7 @@ func (in *ServiceRouteDestination) toConsul() *capi.ServiceRouteDestination {
Namespace: in.Namespace,
Partition: in.Partition,
PrefixRewrite: in.PrefixRewrite,
IdleTimeout: in.IdleTimeout.Duration,
RequestTimeout: in.RequestTimeout.Duration,
NumRetries: in.NumRetries,
RetryOnConnectFailure: in.RetryOnConnectFailure,
Expand Down
6 changes: 5 additions & 1 deletion control-plane/api/v1alpha1/servicerouter_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestServiceRouter_MatchesConsul(t *testing.T) {
ServiceSubset: "serviceSubset",
Namespace: "namespace",
PrefixRewrite: "prefixRewrite",
IdleTimeout: metav1.Duration{Duration: 1 * time.Second},
RequestTimeout: metav1.Duration{Duration: 1 * time.Second},
NumRetries: 1,
RetryOnConnectFailure: true,
Expand Down Expand Up @@ -155,6 +156,7 @@ func TestServiceRouter_MatchesConsul(t *testing.T) {
ServiceSubset: "serviceSubset",
Namespace: "namespace",
PrefixRewrite: "prefixRewrite",
IdleTimeout: 1 * time.Second,
RequestTimeout: 1 * time.Second,
NumRetries: 1,
RetryOnConnectFailure: true,
Expand Down Expand Up @@ -280,6 +282,7 @@ func TestServiceRouter_ToConsul(t *testing.T) {
ServiceSubset: "serviceSubset",
Namespace: "namespace",
PrefixRewrite: "prefixRewrite",
IdleTimeout: metav1.Duration{Duration: 1 * time.Second},
RequestTimeout: metav1.Duration{Duration: 1 * time.Second},
NumRetries: 1,
RetryOnConnectFailure: true,
Expand Down Expand Up @@ -356,6 +359,7 @@ func TestServiceRouter_ToConsul(t *testing.T) {
ServiceSubset: "serviceSubset",
Namespace: "namespace",
PrefixRewrite: "prefixRewrite",
IdleTimeout: 1 * time.Second,
RequestTimeout: 1 * time.Second,
NumRetries: 1,
RetryOnConnectFailure: true,
Expand Down Expand Up @@ -714,7 +718,7 @@ func TestServiceRouter_Validate(t *testing.T) {
},
namespacesEnabled: false,
expectedErrMsgs: []string{
`servicerouter.consul.hashicorp.com "foo" is invalid: spec.routes[0]: Invalid value: "{\"match\":{\"http\":{}},\"destination\":{\"prefixRewrite\":\"prefixRewrite\",\"requestTimeout\":\"0s\"}}": destination.prefixRewrite requires that either match.http.pathPrefix or match.http.pathExact be configured on this route`,
`servicerouter.consul.hashicorp.com "foo" is invalid: spec.routes[0]: Invalid value: "{\"match\":{\"http\":{}},\"destination\":{\"prefixRewrite\":\"prefixRewrite\",\"idleTimeout\":\"0s\",\"requestTimeout\":\"0s\"}}": destination.prefixRewrite requires that either match.http.pathPrefix or match.http.pathExact be configured on this route`,
},
},
"namespaces disabled: single destination namespace specified": {
Expand Down
1 change: 1 addition & 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 @@ -61,6 +61,10 @@ spec:
description: Destination controls how to proxy the matching
request(s) to a service.
properties:
idleTimeout:
description: IdleTimeout is total amount of time permitted
for the request stream to be idle.
type: string
namespace:
description: Namespace is the Consul namespace to resolve
the service from instead of the current namespace. If
Expand Down

0 comments on commit f888c3a

Please sign in to comment.