Skip to content

Commit

Permalink
Adding support for idleTimeout in Service Router spec (#2156)
Browse files Browse the repository at this point in the history
* Adding support for idleTimeout in Service Router spec
  • Loading branch information
kphatak committed May 29, 2023
1 parent 725e78d commit 1734d98
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
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
Expand Up @@ -140,6 +140,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 @@ -337,6 +340,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
Expand Up @@ -82,6 +82,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 @@ -158,6 +159,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 @@ -283,6 +285,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 @@ -359,6 +362,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 @@ -717,7 +721,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.

Expand Up @@ -64,6 +64,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 1734d98

Please sign in to comment.