Skip to content

Commit 9b7744a

Browse files
authored
Fix: Add missing patch annotations to Compression struct for proper Merge (#6951)
* fix: merge compression annotation Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com> * test: add more compression merge test cases Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com> --------- Signed-off-by: sudipto baral <sudiptobaral.me@gmail.com>
1 parent 44f43ea commit 9b7744a

5 files changed

+905
-1
lines changed

api/v1alpha1/backendtrafficpolicy_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ type BackendTrafficPolicySpec struct {
7474

7575
// The compression config for the http streams.
7676
//
77+
// +patchMergeKey=type
78+
// +patchStrategy=merge
79+
//
7780
// +optional
78-
Compression []*Compression `json:"compression,omitempty"`
81+
Compression []*Compression `json:"compression,omitempty" patchMergeKey:"type" patchStrategy:"merge"`
7982

8083
// ResponseOverride defines the configuration to override specific responses with a custom one.
8184
// If multiple configurations are specified, the first one to match wins.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
gateways:
2+
- apiVersion: gateway.networking.k8s.io/v1
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/v1
18+
kind: HTTPRoute
19+
metadata:
20+
namespace: default
21+
name: httproute-1
22+
spec:
23+
hostnames:
24+
- gateway.envoyproxy.io
25+
parentRefs:
26+
- namespace: envoy-gateway
27+
name: gateway-1
28+
sectionName: http
29+
rules:
30+
- matches:
31+
- path:
32+
value: "/"
33+
backendRefs:
34+
- name: service-1
35+
port: 8080
36+
backendTrafficPolicies:
37+
# Gateway-level policy
38+
- apiVersion: gateway.envoyproxy.io/v1alpha1
39+
kind: BackendTrafficPolicy
40+
metadata:
41+
namespace: envoy-gateway
42+
name: gateway-compression-policy
43+
spec:
44+
targetRef:
45+
group: gateway.networking.k8s.io
46+
kind: Gateway
47+
name: gateway-1
48+
compression:
49+
- type: Gzip
50+
# Route-level policy
51+
- apiVersion: gateway.envoyproxy.io/v1alpha1
52+
kind: BackendTrafficPolicy
53+
metadata:
54+
namespace: default
55+
name: route-compression-policy
56+
spec:
57+
targetRef:
58+
group: gateway.networking.k8s.io
59+
kind: HTTPRoute
60+
name: httproute-1
61+
compression:
62+
- type: Brotli
63+
mergeType: JSONMerge
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
backendTrafficPolicies:
2+
- apiVersion: gateway.envoyproxy.io/v1alpha1
3+
kind: BackendTrafficPolicy
4+
metadata:
5+
creationTimestamp: null
6+
name: route-compression-policy
7+
namespace: default
8+
spec:
9+
compression:
10+
- type: Brotli
11+
mergeType: JSONMerge
12+
targetRef:
13+
group: gateway.networking.k8s.io
14+
kind: HTTPRoute
15+
name: httproute-1
16+
status:
17+
ancestors:
18+
- ancestorRef:
19+
group: gateway.networking.k8s.io
20+
kind: Gateway
21+
name: gateway-1
22+
namespace: envoy-gateway
23+
conditions:
24+
- lastTransitionTime: null
25+
message: Merged with policy envoy-gateway/gateway-compression-policy
26+
reason: Merged
27+
status: "True"
28+
type: Merged
29+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
30+
- ancestorRef:
31+
group: gateway.networking.k8s.io
32+
kind: Gateway
33+
name: gateway-1
34+
namespace: envoy-gateway
35+
sectionName: http
36+
conditions:
37+
- lastTransitionTime: null
38+
message: Policy has been accepted.
39+
reason: Accepted
40+
status: "True"
41+
type: Accepted
42+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
43+
- apiVersion: gateway.envoyproxy.io/v1alpha1
44+
kind: BackendTrafficPolicy
45+
metadata:
46+
creationTimestamp: null
47+
name: gateway-compression-policy
48+
namespace: envoy-gateway
49+
spec:
50+
compression:
51+
- type: Gzip
52+
targetRef:
53+
group: gateway.networking.k8s.io
54+
kind: Gateway
55+
name: gateway-1
56+
status:
57+
ancestors:
58+
- ancestorRef:
59+
group: gateway.networking.k8s.io
60+
kind: Gateway
61+
name: gateway-1
62+
namespace: envoy-gateway
63+
conditions:
64+
- lastTransitionTime: null
65+
message: Policy has been accepted.
66+
reason: Accepted
67+
status: "True"
68+
type: Accepted
69+
- lastTransitionTime: null
70+
message: 'This policy is being merged by other backendTrafficPolicies for
71+
these routes: [default/httproute-1]'
72+
reason: Merged
73+
status: "True"
74+
type: Merged
75+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
76+
gateways:
77+
- apiVersion: gateway.networking.k8s.io/v1
78+
kind: Gateway
79+
metadata:
80+
creationTimestamp: null
81+
name: gateway-1
82+
namespace: envoy-gateway
83+
spec:
84+
gatewayClassName: envoy-gateway-class
85+
listeners:
86+
- allowedRoutes:
87+
namespaces:
88+
from: All
89+
name: http
90+
port: 80
91+
protocol: HTTP
92+
status:
93+
listeners:
94+
- attachedRoutes: 1
95+
conditions:
96+
- lastTransitionTime: null
97+
message: Sending translated listener configuration to the data plane
98+
reason: Programmed
99+
status: "True"
100+
type: Programmed
101+
- lastTransitionTime: null
102+
message: Listener has been successfully translated
103+
reason: Accepted
104+
status: "True"
105+
type: Accepted
106+
- lastTransitionTime: null
107+
message: Listener references have been resolved
108+
reason: ResolvedRefs
109+
status: "True"
110+
type: ResolvedRefs
111+
name: http
112+
supportedKinds:
113+
- group: gateway.networking.k8s.io
114+
kind: HTTPRoute
115+
- group: gateway.networking.k8s.io
116+
kind: GRPCRoute
117+
httpRoutes:
118+
- apiVersion: gateway.networking.k8s.io/v1
119+
kind: HTTPRoute
120+
metadata:
121+
creationTimestamp: null
122+
name: httproute-1
123+
namespace: default
124+
spec:
125+
hostnames:
126+
- gateway.envoyproxy.io
127+
parentRefs:
128+
- name: gateway-1
129+
namespace: envoy-gateway
130+
sectionName: http
131+
rules:
132+
- backendRefs:
133+
- name: service-1
134+
port: 8080
135+
matches:
136+
- path:
137+
value: /
138+
status:
139+
parents:
140+
- conditions:
141+
- lastTransitionTime: null
142+
message: Route is accepted
143+
reason: Accepted
144+
status: "True"
145+
type: Accepted
146+
- lastTransitionTime: null
147+
message: Resolved all the Object references for the Route
148+
reason: ResolvedRefs
149+
status: "True"
150+
type: ResolvedRefs
151+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
152+
parentRef:
153+
name: gateway-1
154+
namespace: envoy-gateway
155+
sectionName: http
156+
infraIR:
157+
envoy-gateway/gateway-1:
158+
proxy:
159+
listeners:
160+
- address: null
161+
name: envoy-gateway/gateway-1/http
162+
ports:
163+
- containerPort: 10080
164+
name: http-80
165+
protocol: HTTP
166+
servicePort: 80
167+
metadata:
168+
labels:
169+
gateway.envoyproxy.io/owning-gateway-name: gateway-1
170+
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway
171+
ownerReference:
172+
kind: GatewayClass
173+
name: envoy-gateway-class
174+
name: envoy-gateway/gateway-1
175+
namespace: envoy-gateway-system
176+
xdsIR:
177+
envoy-gateway/gateway-1:
178+
accessLog:
179+
json:
180+
- path: /dev/stdout
181+
globalResources:
182+
proxyServiceCluster:
183+
name: envoy-gateway/gateway-1
184+
settings:
185+
- addressType: IP
186+
endpoints:
187+
- host: 7.6.5.4
188+
port: 8080
189+
zone: zone1
190+
metadata:
191+
name: envoy-envoy-gateway-gateway-1-196ae069
192+
namespace: envoy-gateway-system
193+
sectionName: "8080"
194+
name: envoy-gateway/gateway-1
195+
protocol: TCP
196+
http:
197+
- address: 0.0.0.0
198+
externalPort: 80
199+
hostnames:
200+
- '*'
201+
isHTTP2: false
202+
metadata:
203+
kind: Gateway
204+
name: gateway-1
205+
namespace: envoy-gateway
206+
sectionName: http
207+
name: envoy-gateway/gateway-1/http
208+
path:
209+
escapedSlashesAction: UnescapeAndRedirect
210+
mergeSlashes: true
211+
port: 10080
212+
routes:
213+
- destination:
214+
metadata:
215+
kind: HTTPRoute
216+
name: httproute-1
217+
namespace: default
218+
name: httproute/default/httproute-1/rule/0
219+
settings:
220+
- addressType: IP
221+
endpoints:
222+
- host: 7.7.7.7
223+
port: 8080
224+
metadata:
225+
name: service-1
226+
namespace: default
227+
sectionName: "8080"
228+
name: httproute/default/httproute-1/rule/0/backend/0
229+
protocol: HTTP
230+
weight: 1
231+
hostname: gateway.envoyproxy.io
232+
isHTTP2: false
233+
metadata:
234+
kind: HTTPRoute
235+
name: httproute-1
236+
namespace: default
237+
name: httproute/default/httproute-1/rule/0/match/0/gateway_envoyproxy_io
238+
pathMatch:
239+
distinct: false
240+
name: ""
241+
prefix: /
242+
traffic:
243+
compression:
244+
- type: Brotli
245+
readyListener:
246+
address: 0.0.0.0
247+
ipFamily: IPv4
248+
path: /ready
249+
port: 19003

0 commit comments

Comments
 (0)