Skip to content

Commit 4e4a93d

Browse files
author
Arko Dasgupta
committed
only implement timeout, not retry
Signed-off-by: Arko Dasgupta <[email protected]>
1 parent 1688310 commit 4e4a93d

14 files changed

+420
-15
lines changed

internal/gatewayapi/route.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
"strings"
1111
"time"
1212

13-
"google.golang.org/protobuf/types/known/durationpb"
1413
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1514
"sigs.k8s.io/gateway-api/apis/v1alpha2"
1615
"sigs.k8s.io/gateway-api/apis/v1beta1"
1716

1817
"github.com/envoyproxy/gateway/internal/ir"
18+
"github.com/envoyproxy/gateway/internal/utils/ptr"
1919
)
2020

2121
var (
@@ -192,13 +192,15 @@ func processTimeout(irRoute *ir.HTTPRoute, rule v1beta1.HTTPRouteRule) {
192192
if rule.Timeouts.Request != nil {
193193
// TODO: handle parse errors
194194
d, _ := time.ParseDuration(string(*rule.Timeouts.Request))
195-
irRoute.Timeout = durationpb.New(d)
195+
irRoute.Timeout = ptr.To(metav1.Duration{Duration: d})
196196
}
197197

198+
// Also set the IR Route Timeout to the backend request timeout
199+
// until we introduce retries, then set it to per try timeout
198200
if rule.Timeouts.BackendRequest != nil {
199201
// TODO: handle parse errors
200202
d, _ := time.ParseDuration(string(*rule.Timeouts.BackendRequest))
201-
irRoute.PerTryTimeout = durationpb.New(d)
203+
irRoute.Timeout = ptr.To(metav1.Duration{Duration: d})
202204
}
203205
}
204206
}
@@ -558,7 +560,6 @@ func (t *Translator) processHTTPRouteParentRefListener(route RouteContext, route
558560
RequestAuthentication: routeRoute.RequestAuthentication,
559561
RateLimit: routeRoute.RateLimit,
560562
Timeout: routeRoute.Timeout,
561-
PerTryTimeout: routeRoute.PerTryTimeout,
562563
ExtensionRefs: routeRoute.ExtensionRefs,
563564
}
564565
// Don't bother copying over the weights unless the route has invalid backends.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
gateways:
2+
- apiVersion: gateway.networking.k8s.io/v1beta1
3+
kind: Gateway
4+
metadata:
5+
namespace: envoy-gateway
6+
name: gateway-1
7+
spec:
8+
gatewayClassName: envoy-gateway-class
9+
listeners:
10+
- name: http
11+
protocol: HTTP
12+
port: 80
13+
allowedRoutes:
14+
namespaces:
15+
from: All
16+
httpRoutes:
17+
- apiVersion: gateway.networking.k8s.io/v1beta1
18+
kind: HTTPRoute
19+
metadata:
20+
namespace: default
21+
name: httproute-1
22+
spec:
23+
parentRefs:
24+
- namespace: envoy-gateway
25+
name: gateway-1
26+
sectionName: http
27+
rules:
28+
- matches:
29+
- path:
30+
value: "/"
31+
timeouts:
32+
backendRequest: 1s
33+
backendRefs:
34+
- name: service-1
35+
port: 8080
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
gateways:
2+
- apiVersion: gateway.networking.k8s.io/v1beta1
3+
kind: Gateway
4+
metadata:
5+
creationTimestamp: null
6+
name: gateway-1
7+
namespace: envoy-gateway
8+
spec:
9+
gatewayClassName: envoy-gateway-class
10+
listeners:
11+
- allowedRoutes:
12+
namespaces:
13+
from: All
14+
name: http
15+
port: 80
16+
protocol: HTTP
17+
status:
18+
listeners:
19+
- attachedRoutes: 1
20+
conditions:
21+
- lastTransitionTime: null
22+
message: Sending translated listener configuration to the data plane
23+
reason: Programmed
24+
status: "True"
25+
type: Programmed
26+
- lastTransitionTime: null
27+
message: Listener has been successfully translated
28+
reason: Accepted
29+
status: "True"
30+
type: Accepted
31+
name: http
32+
supportedKinds:
33+
- group: gateway.networking.k8s.io
34+
kind: HTTPRoute
35+
- group: gateway.networking.k8s.io
36+
kind: GRPCRoute
37+
httpRoutes:
38+
- apiVersion: gateway.networking.k8s.io/v1beta1
39+
kind: HTTPRoute
40+
metadata:
41+
creationTimestamp: null
42+
name: httproute-1
43+
namespace: default
44+
spec:
45+
parentRefs:
46+
- name: gateway-1
47+
namespace: envoy-gateway
48+
sectionName: http
49+
rules:
50+
- backendRefs:
51+
- name: service-1
52+
port: 8080
53+
matches:
54+
- path:
55+
value: /
56+
timeouts:
57+
backendRequest: 1s
58+
status:
59+
parents:
60+
- conditions:
61+
- lastTransitionTime: null
62+
message: Route is accepted
63+
reason: Accepted
64+
status: "True"
65+
type: Accepted
66+
- lastTransitionTime: null
67+
message: Resolved all the Object references for the Route
68+
reason: ResolvedRefs
69+
status: "True"
70+
type: ResolvedRefs
71+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
72+
parentRef:
73+
name: gateway-1
74+
namespace: envoy-gateway
75+
sectionName: http
76+
infraIR:
77+
envoy-gateway/gateway-1:
78+
proxy:
79+
listeners:
80+
- address: ""
81+
ports:
82+
- containerPort: 10080
83+
name: http
84+
protocol: HTTP
85+
servicePort: 80
86+
metadata:
87+
labels:
88+
gateway.envoyproxy.io/owning-gateway-name: gateway-1
89+
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway
90+
name: envoy-gateway/gateway-1
91+
xdsIR:
92+
envoy-gateway/gateway-1:
93+
accessLog:
94+
text:
95+
- path: /dev/stdout
96+
http:
97+
- address: 0.0.0.0
98+
hostnames:
99+
- '*'
100+
isHTTP2: false
101+
name: envoy-gateway/gateway-1/http
102+
port: 10080
103+
routes:
104+
- backendWeights:
105+
invalid: 0
106+
valid: 0
107+
destination:
108+
endpoints:
109+
- host: 7.7.7.7
110+
port: 8080
111+
weight: 1
112+
name: httproute/default/httproute-1/rule/0
113+
hostname: '*'
114+
name: httproute/default/httproute-1/rule/0/match/0/*
115+
pathMatch:
116+
distinct: false
117+
name: ""
118+
prefix: /
119+
timeout: 1s
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
gateways:
2+
- apiVersion: gateway.networking.k8s.io/v1beta1
3+
kind: Gateway
4+
metadata:
5+
namespace: envoy-gateway
6+
name: gateway-1
7+
spec:
8+
gatewayClassName: envoy-gateway-class
9+
listeners:
10+
- name: http
11+
protocol: HTTP
12+
port: 80
13+
allowedRoutes:
14+
namespaces:
15+
from: All
16+
httpRoutes:
17+
- apiVersion: gateway.networking.k8s.io/v1beta1
18+
kind: HTTPRoute
19+
metadata:
20+
namespace: default
21+
name: httproute-1
22+
spec:
23+
parentRefs:
24+
- namespace: envoy-gateway
25+
name: gateway-1
26+
sectionName: http
27+
rules:
28+
- matches:
29+
- path:
30+
value: "/"
31+
timeouts:
32+
request: 5s
33+
backendRefs:
34+
- name: service-1
35+
port: 8080
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
gateways:
2+
- apiVersion: gateway.networking.k8s.io/v1beta1
3+
kind: Gateway
4+
metadata:
5+
creationTimestamp: null
6+
name: gateway-1
7+
namespace: envoy-gateway
8+
spec:
9+
gatewayClassName: envoy-gateway-class
10+
listeners:
11+
- allowedRoutes:
12+
namespaces:
13+
from: All
14+
name: http
15+
port: 80
16+
protocol: HTTP
17+
status:
18+
listeners:
19+
- attachedRoutes: 1
20+
conditions:
21+
- lastTransitionTime: null
22+
message: Sending translated listener configuration to the data plane
23+
reason: Programmed
24+
status: "True"
25+
type: Programmed
26+
- lastTransitionTime: null
27+
message: Listener has been successfully translated
28+
reason: Accepted
29+
status: "True"
30+
type: Accepted
31+
name: http
32+
supportedKinds:
33+
- group: gateway.networking.k8s.io
34+
kind: HTTPRoute
35+
- group: gateway.networking.k8s.io
36+
kind: GRPCRoute
37+
httpRoutes:
38+
- apiVersion: gateway.networking.k8s.io/v1beta1
39+
kind: HTTPRoute
40+
metadata:
41+
creationTimestamp: null
42+
name: httproute-1
43+
namespace: default
44+
spec:
45+
parentRefs:
46+
- name: gateway-1
47+
namespace: envoy-gateway
48+
sectionName: http
49+
rules:
50+
- backendRefs:
51+
- name: service-1
52+
port: 8080
53+
matches:
54+
- path:
55+
value: /
56+
timeouts:
57+
request: 5s
58+
status:
59+
parents:
60+
- conditions:
61+
- lastTransitionTime: null
62+
message: Route is accepted
63+
reason: Accepted
64+
status: "True"
65+
type: Accepted
66+
- lastTransitionTime: null
67+
message: Resolved all the Object references for the Route
68+
reason: ResolvedRefs
69+
status: "True"
70+
type: ResolvedRefs
71+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
72+
parentRef:
73+
name: gateway-1
74+
namespace: envoy-gateway
75+
sectionName: http
76+
infraIR:
77+
envoy-gateway/gateway-1:
78+
proxy:
79+
listeners:
80+
- address: ""
81+
ports:
82+
- containerPort: 10080
83+
name: http
84+
protocol: HTTP
85+
servicePort: 80
86+
metadata:
87+
labels:
88+
gateway.envoyproxy.io/owning-gateway-name: gateway-1
89+
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway
90+
name: envoy-gateway/gateway-1
91+
xdsIR:
92+
envoy-gateway/gateway-1:
93+
accessLog:
94+
text:
95+
- path: /dev/stdout
96+
http:
97+
- address: 0.0.0.0
98+
hostnames:
99+
- '*'
100+
isHTTP2: false
101+
name: envoy-gateway/gateway-1/http
102+
port: 10080
103+
routes:
104+
- backendWeights:
105+
invalid: 0
106+
valid: 0
107+
destination:
108+
endpoints:
109+
- host: 7.7.7.7
110+
port: 8080
111+
weight: 1
112+
name: httproute/default/httproute-1/rule/0
113+
hostname: '*'
114+
name: httproute/default/httproute-1/rule/0/match/0/*
115+
pathMatch:
116+
distinct: false
117+
name: ""
118+
prefix: /
119+
timeout: 5s

internal/ir/xds.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/tetratelabs/multierror"
1414
"golang.org/x/exp/slices"
1515

16-
"google.golang.org/protobuf/types/known/durationpb"
1716
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
17+
"k8s.io/apimachinery/pkg/apis/meta/v1"
1818
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1919

2020
egcfgv1a1 "github.com/envoyproxy/gateway/api/config/v1alpha1"
@@ -275,9 +275,7 @@ type HTTPRoute struct {
275275
// RequestAuthentication defines the schema for authenticating HTTP requests.
276276
RequestAuthentication *RequestAuthentication `json:"requestAuthentication,omitempty" yaml:"requestAuthentication,omitempty"`
277277
// Timeout is the time until which entire response is received from the upstream.
278-
Timeout *durationpb.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
279-
// PerTryTimeout is the timeout per retry attempt. Number of retries defaults to 1.
280-
PerTryTimeout *durationpb.Duration `json:"perTryTimeout,omitempty" yaml:"perTryTimeout,omitempty"`
278+
Timeout *v1.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
281279
// ExtensionRefs holds unstructured resources that were introduced by an extension and used on the HTTPRoute as extensionRef filters
282280
ExtensionRefs []*UnstructuredRef `json:"extensionRefs,omitempty" yaml:"extensionRefs,omitempty"`
283281
}

internal/ir/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)