Skip to content

Commit 07b6933

Browse files
committed
check redirect respose filter
Signed-off-by: Huabing Zhao <[email protected]>
1 parent f7a0e10 commit 07b6933

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

internal/gatewayapi/filters.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type HTTPFilterIR struct {
7070
var HeaderValueRegexp = regexp.MustCompile(`^[!-~]+([\t ]?[!-~]+)*$`)
7171

7272
const requestMirrorDirectResponseConflictMsg = "RequestMirror filter cannot be used when the rule also configures a DirectResponse filter"
73+
const requestMirrorRedirectConflictMsg = "RequestMirror filter cannot be used when the rule also configures a RequestRedirect filter"
7374

7475
// ProcessHTTPFilters translates gateway api http filters to IRs.
7576
func (t *Translator) ProcessHTTPFilters(parentRef *RouteParentContext,
@@ -116,9 +117,13 @@ func (t *Translator) ProcessHTTPFilters(parentRef *RouteParentContext,
116117
}
117118
}
118119

120+
// Check for conflicts between RequestMirror and DirectResponse or RequestRedirect filters
119121
if httpFiltersContext.DirectResponse != nil && len(httpFiltersContext.Mirrors) > 0 {
120122
updateRouteStatusForFilter(httpFiltersContext, requestMirrorDirectResponseConflictMsg)
121123
}
124+
if httpFiltersContext.RedirectResponse != nil && len(httpFiltersContext.Mirrors) > 0 {
125+
updateRouteStatusForFilter(httpFiltersContext, requestMirrorRedirectConflictMsg)
126+
}
122127

123128
return httpFiltersContext, err
124129
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,34 @@ httpRoutes:
4747
group: gateway.envoyproxy.io
4848
kind: HTTPRouteFilter
4949
name: mirror-direct-response
50+
- apiVersion: gateway.networking.k8s.io/v1
51+
kind: HTTPRoute
52+
metadata:
53+
namespace: default
54+
name: mirror-request-redirect
55+
spec:
56+
hostnames:
57+
- gateway.envoyproxy.io
58+
parentRefs:
59+
- namespace: envoy-gateway
60+
name: gateway-1
61+
sectionName: http
62+
rules:
63+
- matches:
64+
- path:
65+
type: PathPrefix
66+
value: /mirror-redirect
67+
filters:
68+
- type: RequestMirror
69+
requestMirror:
70+
backendRef:
71+
kind: Service
72+
name: service-1
73+
port: 8080
74+
- type: RequestRedirect
75+
requestRedirect:
76+
scheme: https
77+
statusCode: 302
5078
httpFilters:
5179
- apiVersion: gateway.envoyproxy.io/v1alpha1
5280
kind: HTTPRouteFilter
Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ gateways:
1616
protocol: HTTP
1717
status:
1818
listeners:
19-
- attachedRoutes: 1
19+
- attachedRoutes: 2
2020
conditions:
2121
- lastTransitionTime: null
2222
message: Sending translated listener configuration to the data plane
@@ -91,6 +91,53 @@ httpRoutes:
9191
name: gateway-1
9292
namespace: envoy-gateway
9393
sectionName: http
94+
- apiVersion: gateway.networking.k8s.io/v1
95+
kind: HTTPRoute
96+
metadata:
97+
name: mirror-request-redirect
98+
namespace: default
99+
spec:
100+
hostnames:
101+
- gateway.envoyproxy.io
102+
parentRefs:
103+
- name: gateway-1
104+
namespace: envoy-gateway
105+
sectionName: http
106+
rules:
107+
- filters:
108+
- requestMirror:
109+
backendRef:
110+
kind: Service
111+
name: service-1
112+
port: 8080
113+
type: RequestMirror
114+
- requestRedirect:
115+
scheme: https
116+
statusCode: 302
117+
type: RequestRedirect
118+
matches:
119+
- path:
120+
type: PathPrefix
121+
value: /mirror-redirect
122+
status:
123+
parents:
124+
- conditions:
125+
- lastTransitionTime: null
126+
message: RequestMirror filter cannot be used when the rule also configures
127+
a RequestRedirect filter
128+
reason: UnsupportedValue
129+
status: "False"
130+
type: Accepted
131+
- lastTransitionTime: null
132+
message: Resolved all the Object references for the Route
133+
reason: ResolvedRefs
134+
status: "True"
135+
type: ResolvedRefs
136+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
137+
parentRef:
138+
name: gateway-1
139+
namespace: envoy-gateway
140+
sectionName: http
94141
infraIR:
95142
envoy-gateway/gateway-1:
96143
proxy:

0 commit comments

Comments
 (0)