From 6419d7eb99d280ba90f10e2d99c68c6f66e09c9a Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Wed, 9 Apr 2025 05:03:17 +0200 Subject: [PATCH] [Feature] [Platform] Adjust Gateway Timeouts --- CHANGELOG.md | 1 + docs/api/ArangoRoute.V1Alpha1.md | 8 ++++---- pkg/apis/networking/v1alpha1/route_spec_destination.go | 9 +++++++++ pkg/util/constants/gateway.go | 8 +++++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6af68bb2..36fd6d90f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - (Feature) Add Default Container Mods - (Documentation) Improve Charts and Upgrade Documentation - (Feature) AutoDiscover Operator Access +- (Feature) (Platform) Adjust Gateway timeouts ## [1.2.47](https://github.com/arangodb/kube-arangodb/tree/1.2.47) (2025-03-28) - (Bugfix) Use Profile Annotations diff --git a/docs/api/ArangoRoute.V1Alpha1.md b/docs/api/ArangoRoute.V1Alpha1.md index 2f4f41670..fab23e1bc 100644 --- a/docs/api/ArangoRoute.V1Alpha1.md +++ b/docs/api/ArangoRoute.V1Alpha1.md @@ -83,7 +83,7 @@ UID keeps the information about object UID ### .spec.destination.path -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L51) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L52) Path defines service path used for overrides @@ -91,7 +91,7 @@ Path defines service path used for overrides ### .spec.destination.protocol -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L45) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L46) Protocol defines http protocol used for the route @@ -103,7 +103,7 @@ Possible Values: ### .spec.destination.schema -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L40) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L41) Schema defines HTTP/S schema used for connection @@ -155,7 +155,7 @@ UID keeps the information about object UID ### .spec.destination.timeout -Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L59) +Type: `string` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.47/pkg/apis/networking/v1alpha1/route_spec_destination.go#L60) Timeout specify the upstream request timeout diff --git a/pkg/apis/networking/v1alpha1/route_spec_destination.go b/pkg/apis/networking/v1alpha1/route_spec_destination.go index cd125be72..b2f1a1d53 100644 --- a/pkg/apis/networking/v1alpha1/route_spec_destination.go +++ b/pkg/apis/networking/v1alpha1/route_spec_destination.go @@ -25,6 +25,7 @@ import ( shared "github.com/arangodb/kube-arangodb/pkg/apis/shared" "github.com/arangodb/kube-arangodb/pkg/util/constants" + "github.com/arangodb/kube-arangodb/pkg/util/errors" ) type ArangoRouteSpecDestination struct { @@ -139,6 +140,14 @@ func (a *ArangoRouteSpecDestination) Validate() error { shared.ValidateOptionalInterfacePath("tls", a.TLS), shared.ValidateOptionalInterfacePath("authentication", a.Authentication), shared.PrefixResourceError("path", shared.ValidateAPIPath(a.GetPath())), + shared.PrefixResourceErrorFunc("timeout", func() error { + if t := a.GetTimeout(); t.Duration < constants.MinEnvoyUpstreamTimeout { + return errors.Errorf("Timeout lower than %s not allowed", constants.MinEnvoyUpstreamTimeout.String()) + } else if t.Duration > constants.MaxEnvoyUpstreamTimeout { + return errors.Errorf("Timeout greater than %s not allowed", constants.MaxEnvoyUpstreamTimeout.String()) + } + return nil + }), ); err != nil { return err } diff --git a/pkg/util/constants/gateway.go b/pkg/util/constants/gateway.go index 28c089428..2438b03c6 100644 --- a/pkg/util/constants/gateway.go +++ b/pkg/util/constants/gateway.go @@ -20,12 +20,14 @@ package constants -import "time" +import ( + "time" +) const ( DefaultEnvoyUpstreamTimeout = time.Minute - MaxEnvoyUpstreamTimeout = 15 * time.Minute - MinEnvoyUpstreamTimeout = 15 * time.Second + MaxEnvoyUpstreamTimeout = time.Hour + MinEnvoyUpstreamTimeout = time.Duration(0) ConfigMapChecksumKey = "CHECKSUM"