Skip to content

Commit c74c63e

Browse files
committed
1 parent 51ad33d commit c74c63e

File tree

5 files changed

+172
-2
lines changed

5 files changed

+172
-2
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,5 @@ require (
250250
sigs.k8s.io/kustomize/kyaml v0.14.3 // indirect
251251
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
252252
)
253+
254+
replace sigs.k8s.io/gateway-api => /Users/simone/go/src/sigs.k8s.io/gateway-api

pilot/pkg/config/kube/gateway/conversion.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"sort"
2323
"strings"
2424

25+
"google.golang.org/protobuf/types/known/durationpb"
2526
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2627
klabels "k8s.io/apimachinery/pkg/labels"
2728
k8s "sigs.k8s.io/gateway-api/apis/v1alpha2"
@@ -42,6 +43,8 @@ import (
4243
"istio.io/istio/pkg/ptr"
4344
"istio.io/istio/pkg/slices"
4445
"istio.io/istio/pkg/util/sets"
46+
47+
time "time"
4548
)
4649

4750
func sortConfigByCreationTime(configs []config.Config) {
@@ -271,6 +274,26 @@ func convertHTTPRoute(r k8s.HTTPRouteRule, ctx configContext,
271274
return vs, backendErr
272275
}
273276

277+
if r.Timeouts != nil {
278+
if r.Timeouts.Request != nil {
279+
request, _ := time.ParseDuration((string)(*r.Timeouts.Request))
280+
if request != 0 {
281+
vs.Timeout = durationpb.New(request)
282+
}
283+
}
284+
if r.Timeouts.BackendRequest != nil {
285+
backendRequest, _ := time.ParseDuration((string)(*r.Timeouts.BackendRequest))
286+
if backendRequest != 0 {
287+
timeout := durationpb.New(backendRequest)
288+
if vs.Retries != nil {
289+
vs.Retries.PerTryTimeout = timeout
290+
} else {
291+
vs.Timeout = timeout
292+
}
293+
}
294+
}
295+
}
296+
274297
return vs, nil
275298
}
276299

pilot/pkg/config/kube/gateway/testdata/http.status.yaml.golden

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ status:
3636
status: "True"
3737
type: Programmed
3838
listeners:
39-
- attachedRoutes: 6
39+
- attachedRoutes: 8
4040
conditions:
4141
- lastTransitionTime: fake
4242
message: No errors found
@@ -117,6 +117,56 @@ status:
117117
---
118118
apiVersion: gateway.networking.k8s.io/v1beta1
119119
kind: HTTPRoute
120+
metadata:
121+
creationTimestamp: null
122+
name: http-timeout-backend-request
123+
namespace: default
124+
spec: null
125+
status:
126+
parents:
127+
- conditions:
128+
- lastTransitionTime: fake
129+
message: Route was valid
130+
reason: Accepted
131+
status: "True"
132+
type: Accepted
133+
- lastTransitionTime: fake
134+
message: All references resolved
135+
reason: ResolvedRefs
136+
status: "True"
137+
type: ResolvedRefs
138+
controllerName: istio.io/gateway-controller
139+
parentRef:
140+
name: gateway
141+
namespace: istio-system
142+
---
143+
apiVersion: gateway.networking.k8s.io/v1beta1
144+
kind: HTTPRoute
145+
metadata:
146+
creationTimestamp: null
147+
name: http-timeout-request
148+
namespace: default
149+
spec: null
150+
status:
151+
parents:
152+
- conditions:
153+
- lastTransitionTime: fake
154+
message: Route was valid
155+
reason: Accepted
156+
status: "True"
157+
type: Accepted
158+
- lastTransitionTime: fake
159+
message: All references resolved
160+
reason: ResolvedRefs
161+
status: "True"
162+
type: ResolvedRefs
163+
controllerName: istio.io/gateway-controller
164+
parentRef:
165+
name: gateway
166+
namespace: istio-system
167+
---
168+
apiVersion: gateway.networking.k8s.io/v1beta1
169+
kind: HTTPRoute
120170
metadata:
121171
creationTimestamp: null
122172
name: http2

pilot/pkg/config/kube/gateway/testdata/http.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,47 @@ spec:
214214
value: /get
215215
backendRefs:
216216
- name: httpbin-bad
217-
port: 80
217+
port: 80
218+
---
219+
apiVersion: gateway.networking.k8s.io/v1beta1
220+
kind: HTTPRoute
221+
metadata:
222+
name: http-timeout-request
223+
namespace: default
224+
spec:
225+
parentRefs:
226+
- name: gateway
227+
namespace: istio-system
228+
hostnames: ["timeout.domain.example"]
229+
rules:
230+
- matches:
231+
- path:
232+
type: PathPrefix
233+
value: /get
234+
backendRefs:
235+
- name: httpbin
236+
port: 80
237+
timeouts:
238+
request: 1ms
239+
---
240+
apiVersion: gateway.networking.k8s.io/v1beta1
241+
kind: HTTPRoute
242+
metadata:
243+
name: http-timeout-backend-request
244+
namespace: default
245+
spec:
246+
parentRefs:
247+
- name: gateway
248+
namespace: istio-system
249+
hostnames: ["timeout-backend.domain.example"]
250+
rules:
251+
- matches:
252+
- path:
253+
type: PathPrefix
254+
value: /get
255+
backendRefs:
256+
- name: httpbin
257+
port: 80
258+
timeouts:
259+
request: 2ms
260+
backendRequest: 1ms

pilot/pkg/config/kube/gateway/testdata/http.yaml.golden

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,58 @@ spec:
9696
---
9797
apiVersion: networking.istio.io/v1alpha3
9898
kind: VirtualService
99+
metadata:
100+
annotations:
101+
internal.istio.io/parents: HTTPRoute/http-timeout-backend-request.default
102+
internal.istio.io/route-semantics: gateway
103+
creationTimestamp: null
104+
name: http-timeout-backend-request-0-istio-autogenerated-k8s-gateway
105+
namespace: default
106+
spec:
107+
gateways:
108+
- istio-system/gateway-istio-autogenerated-k8s-gateway-default
109+
hosts:
110+
- timeout-backend.domain.example
111+
http:
112+
- match:
113+
- uri:
114+
prefix: /get
115+
name: default.http-timeout-backend-request.0
116+
route:
117+
- destination:
118+
host: httpbin.default.svc.domain.suffix
119+
port:
120+
number: 80
121+
timeout: 0.001s
122+
---
123+
apiVersion: networking.istio.io/v1alpha3
124+
kind: VirtualService
125+
metadata:
126+
annotations:
127+
internal.istio.io/parents: HTTPRoute/http-timeout-request.default
128+
internal.istio.io/route-semantics: gateway
129+
creationTimestamp: null
130+
name: http-timeout-request-0-istio-autogenerated-k8s-gateway
131+
namespace: default
132+
spec:
133+
gateways:
134+
- istio-system/gateway-istio-autogenerated-k8s-gateway-default
135+
hosts:
136+
- timeout.domain.example
137+
http:
138+
- match:
139+
- uri:
140+
prefix: /get
141+
name: default.http-timeout-request.0
142+
route:
143+
- destination:
144+
host: httpbin.default.svc.domain.suffix
145+
port:
146+
number: 80
147+
timeout: 0.001s
148+
---
149+
apiVersion: networking.istio.io/v1alpha3
150+
kind: VirtualService
99151
metadata:
100152
annotations:
101153
internal.istio.io/parents: HTTPRoute/http2.default

0 commit comments

Comments
 (0)