Skip to content

Commit 67059bc

Browse files
authored
[Feature] [Platform] ArangoRoute Timeout option (#1826)
1 parent 6626f61 commit 67059bc

17 files changed

+157
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- (Bugfix) Agency Cache Reload
1515
- (Feature) Allow to continue if ResignServer job is gone
1616
- (Feature) UpgradeByReplace Flow
17+
- (Feature) (Platform) ArangoRoute Timeout option
1718

1819
## [1.2.44](https://github.com/arangodb/kube-arangodb/tree/1.2.44) (2025-02-03)
1920
- (Maintenance) Kubernetes 1.31.1 libraries

docs/api/ArangoDeployment.V1.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.
30823082

30833083
### .spec.gateway.dynamic
30843084

3085-
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L36)</sup>
3085+
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L41)</sup>
30863086

30873087
Dynamic setting enables/disables support dynamic configuration of the gateway in the cluster.
30883088
When enabled, gateway config will be reloaded by ConfigMap live updates.
@@ -3093,7 +3093,7 @@ Default Value: `false`
30933093

30943094
### .spec.gateway.enabled
30953095

3096-
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L31)</sup>
3096+
Type: `boolean` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L36)</sup>
30973097

30983098
Enabled setting enables/disables support for gateway in the cluster.
30993099
When enabled, the cluster will contain a number of `gateway` servers.
@@ -3104,13 +3104,23 @@ Default Value: `false`
31043104

31053105
### .spec.gateway.image
31063106

3107-
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L40)</sup>
3107+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L45)</sup>
31083108

31093109
Image is the image to use for the gateway.
31103110
By default, the image is determined by the operator.
31113111

31123112
***
31133113

3114+
### .spec.gateway.timeout
3115+
3116+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/deployment_spec_gateway.go#L50)</sup>
3117+
3118+
Timeout defines default timeout for the upstream actions (if not overridden)
3119+
3120+
Default Value: `1m0s`
3121+
3122+
***
3123+
31143124
### .spec.gateways.affinity
31153125

31163126
Type: `core.PodAffinity` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/deployment/v1/server_group_spec.go#L156)</sup>

docs/api/ArangoRoute.V1Alpha1.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ UID keeps the information about object UID
155155

156156
### .spec.destination.timeout
157157

158-
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/networking/v1alpha1/route_spec_destination.go#L57)</sup>
158+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.44/pkg/apis/networking/v1alpha1/route_spec_destination.go#L59)</sup>
159159

160160
Timeout specify the upstream request timeout
161161

162+
Default Value: `1m0s`
163+
162164
***
163165

164166
### .spec.destination.tls.insecure

pkg/apis/deployment/v1/deployment_spec_gateway.go

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,7 +21,12 @@
2121
package v1
2222

2323
import (
24+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
26+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
2427
"github.com/arangodb/kube-arangodb/pkg/util"
28+
"github.com/arangodb/kube-arangodb/pkg/util/constants"
29+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2530
)
2631

2732
type DeploymentSpecGateway struct {
@@ -37,7 +42,12 @@ type DeploymentSpecGateway struct {
3742

3843
// Image is the image to use for the gateway.
3944
// By default, the image is determined by the operator.
40-
Image *string `json:"image"`
45+
Image *string `json:"image,omitempty"`
46+
47+
// Timeout defines default timeout for the upstream actions (if not overridden)
48+
// +doc/type: string
49+
// +doc/default: 1m0s
50+
Timeout *meta.Duration `json:"timeout,omitempty"`
4151
}
4252

4353
// IsEnabled returns whether the gateway is enabled.
@@ -58,9 +68,33 @@ func (d *DeploymentSpecGateway) IsDynamic() bool {
5868
return *d.Dynamic
5969
}
6070

71+
// GetTimeout returns default gateway timeout.
72+
func (d *DeploymentSpecGateway) GetTimeout() meta.Duration {
73+
if d == nil || d.Timeout == nil {
74+
return meta.Duration{
75+
Duration: constants.DefaultEnvoyUpstreamTimeout,
76+
}
77+
}
78+
79+
return *d.Timeout
80+
}
81+
6182
// Validate the given spec
6283
func (d *DeploymentSpecGateway) Validate() error {
63-
return nil
84+
if d == nil {
85+
d = &DeploymentSpecGateway{}
86+
}
87+
88+
return shared.WithErrors(
89+
shared.PrefixResourceErrorFunc("timeout", func() error {
90+
if t := d.GetTimeout(); t.Duration < constants.MinEnvoyUpstreamTimeout {
91+
return errors.Errorf("Timeout lower than %s not allowed", constants.MinEnvoyUpstreamTimeout.String())
92+
} else if t.Duration > constants.MaxEnvoyUpstreamTimeout {
93+
return errors.Errorf("Timeout greater than %s not allowed", constants.MaxEnvoyUpstreamTimeout.String())
94+
}
95+
return nil
96+
}),
97+
)
6498
}
6599

66100
// GetImage returns the image to use for the gateway.

pkg/apis/deployment/v1/timeouts.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -111,3 +111,13 @@ func (t *Timeout) Get(d time.Duration) time.Duration {
111111

112112
return t.Duration
113113
}
114+
115+
// OpenAPISchemaType is used by the kube-openapi generator when constructing
116+
// the OpenAPI spec of this type.
117+
//
118+
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
119+
func (_ *Timeout) OpenAPISchemaType() []string { return []string{"string"} }
120+
121+
// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
122+
// the OpenAPI spec of this type.
123+
func (_ *Timeout) OpenAPISchemaFormat() string { return "" }

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/deployment/v2alpha1/deployment_spec_gateway.go

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2024-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,7 +21,12 @@
2121
package v2alpha1
2222

2323
import (
24+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
26+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
2427
"github.com/arangodb/kube-arangodb/pkg/util"
28+
"github.com/arangodb/kube-arangodb/pkg/util/constants"
29+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2530
)
2631

2732
type DeploymentSpecGateway struct {
@@ -37,7 +42,12 @@ type DeploymentSpecGateway struct {
3742

3843
// Image is the image to use for the gateway.
3944
// By default, the image is determined by the operator.
40-
Image *string `json:"image"`
45+
Image *string `json:"image,omitempty"`
46+
47+
// Timeout defines default timeout for the upstream actions (if not overridden)
48+
// +doc/type: string
49+
// +doc/default: 1m0s
50+
Timeout *meta.Duration `json:"timeout,omitempty"`
4151
}
4252

4353
// IsEnabled returns whether the gateway is enabled.
@@ -58,9 +68,33 @@ func (d *DeploymentSpecGateway) IsDynamic() bool {
5868
return *d.Dynamic
5969
}
6070

71+
// GetTimeout returns default gateway timeout.
72+
func (d *DeploymentSpecGateway) GetTimeout() meta.Duration {
73+
if d == nil || d.Timeout == nil {
74+
return meta.Duration{
75+
Duration: constants.DefaultEnvoyUpstreamTimeout,
76+
}
77+
}
78+
79+
return *d.Timeout
80+
}
81+
6182
// Validate the given spec
6283
func (d *DeploymentSpecGateway) Validate() error {
63-
return nil
84+
if d == nil {
85+
d = &DeploymentSpecGateway{}
86+
}
87+
88+
return shared.WithErrors(
89+
shared.PrefixResourceErrorFunc("timeout", func() error {
90+
if t := d.GetTimeout(); t.Duration < constants.MinEnvoyUpstreamTimeout {
91+
return errors.Errorf("Timeout lower than %s not allowed", constants.MinEnvoyUpstreamTimeout.String())
92+
} else if t.Duration > constants.MaxEnvoyUpstreamTimeout {
93+
return errors.Errorf("Timeout greater than %s not allowed", constants.MaxEnvoyUpstreamTimeout.String())
94+
}
95+
return nil
96+
}),
97+
)
6498
}
6599

66100
// GetImage returns the image to use for the gateway.

pkg/apis/deployment/v2alpha1/timeouts.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -111,3 +111,13 @@ func (t *Timeout) Get(d time.Duration) time.Duration {
111111

112112
return t.Duration
113113
}
114+
115+
// OpenAPISchemaType is used by the kube-openapi generator when constructing
116+
// the OpenAPI spec of this type.
117+
//
118+
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
119+
func (_ *Timeout) OpenAPISchemaType() []string { return []string{"string"} }
120+
121+
// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
122+
// the OpenAPI spec of this type.
123+
func (_ *Timeout) OpenAPISchemaFormat() string { return "" }

pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/networking/v1alpha1/route_spec_destination.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type ArangoRouteSpecDestination struct {
5454
Authentication *ArangoRouteSpecDestinationAuthentication `json:"authentication,omitempty"`
5555

5656
// Timeout specify the upstream request timeout
57+
// +doc/type: string
58+
// +doc/default: 1m0s
5759
Timeout *meta.Duration `json:"timeout,omitempty"`
5860
}
5961

0 commit comments

Comments
 (0)