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

Adding support for idleTimeout in Service Router spec #2156

Merged
merged 4 commits into from May 29, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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