@@ -66,16 +66,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
66
66
r .statusUpdater .Send (Update {
67
67
NamespacedName : key ,
68
68
Resource : new (gwapiv1.HTTPRoute ),
69
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
69
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
70
70
h , ok := obj .(* gwapiv1.HTTPRoute )
71
71
if ! ok {
72
72
err := fmt .Errorf ("unsupported object type %T" , obj )
73
73
errChan <- err
74
74
panic (err )
75
75
}
76
- hCopy := h .DeepCopy ()
77
- hCopy .Status .Parents = val .Parents
78
- return hCopy
76
+
77
+ if isStatusEqual (h .Status .Parents , val .Parents ) {
78
+ return true
79
+ }
80
+
81
+ h .Status .Parents = val .Parents
82
+ return false
79
83
}),
80
84
})
81
85
},
@@ -96,16 +100,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
96
100
r .statusUpdater .Send (Update {
97
101
NamespacedName : key ,
98
102
Resource : new (gwapiv1.GRPCRoute ),
99
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
103
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
100
104
h , ok := obj .(* gwapiv1.GRPCRoute )
101
105
if ! ok {
102
106
err := fmt .Errorf ("unsupported object type %T" , obj )
103
107
errChan <- err
104
108
panic (err )
105
109
}
106
- hCopy := h .DeepCopy ()
107
- hCopy .Status .Parents = val .Parents
108
- return hCopy
110
+
111
+ if isStatusEqual (h .Status .Parents , val .Parents ) {
112
+ return true
113
+ }
114
+
115
+ h .Status .Parents = val .Parents
116
+ return false
109
117
}),
110
118
})
111
119
},
@@ -128,16 +136,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
128
136
r .statusUpdater .Send (Update {
129
137
NamespacedName : key ,
130
138
Resource : new (gwapiv1a2.TLSRoute ),
131
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
139
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
132
140
t , ok := obj .(* gwapiv1a2.TLSRoute )
133
141
if ! ok {
134
142
err := fmt .Errorf ("unsupported object type %T" , obj )
135
143
errChan <- err
136
144
panic (err )
137
145
}
138
- tCopy := t .DeepCopy ()
139
- tCopy .Status .Parents = val .Parents
140
- return tCopy
146
+
147
+ if isStatusEqual (t .Status .Parents , val .Parents ) {
148
+ return true
149
+ }
150
+
151
+ t .Status .Parents = val .Parents
152
+ return false
141
153
}),
142
154
})
143
155
},
@@ -160,16 +172,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
160
172
r .statusUpdater .Send (Update {
161
173
NamespacedName : key ,
162
174
Resource : new (gwapiv1a2.TCPRoute ),
163
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
175
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
164
176
t , ok := obj .(* gwapiv1a2.TCPRoute )
165
177
if ! ok {
166
178
err := fmt .Errorf ("unsupported object type %T" , obj )
167
179
errChan <- err
168
180
panic (err )
169
181
}
170
- tCopy := t .DeepCopy ()
171
- tCopy .Status .Parents = val .Parents
172
- return tCopy
182
+
183
+ if isStatusEqual (t .Status .Parents , val .Parents ) {
184
+ return true
185
+ }
186
+
187
+ t .Status .Parents = val .Parents
188
+ return false
173
189
}),
174
190
})
175
191
},
@@ -192,16 +208,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
192
208
r .statusUpdater .Send (Update {
193
209
NamespacedName : key ,
194
210
Resource : new (gwapiv1a2.UDPRoute ),
195
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
211
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
196
212
t , ok := obj .(* gwapiv1a2.UDPRoute )
197
213
if ! ok {
198
214
err := fmt .Errorf ("unsupported object type %T" , obj )
199
215
errChan <- err
200
216
panic (err )
201
217
}
202
- tCopy := t .DeepCopy ()
203
- tCopy .Status .Parents = val .Parents
204
- return tCopy
218
+
219
+ if isStatusEqual (t .Status .Parents , val .Parents ) {
220
+ return true
221
+ }
222
+
223
+ t .Status .Parents = val .Parents
224
+ return false
205
225
}),
206
226
})
207
227
},
@@ -224,16 +244,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
224
244
r .statusUpdater .Send (Update {
225
245
NamespacedName : key ,
226
246
Resource : new (egv1a1.EnvoyPatchPolicy ),
227
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
247
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
228
248
t , ok := obj .(* egv1a1.EnvoyPatchPolicy )
229
249
if ! ok {
230
250
err := fmt .Errorf ("unsupported object type %T" , obj )
231
251
errChan <- err
232
252
panic (err )
233
253
}
234
- tCopy := t .DeepCopy ()
235
- tCopy .Status = * val
236
- return tCopy
254
+
255
+ if isStatusEqual (t .Status , * val ) {
256
+ return true
257
+ }
258
+
259
+ t .Status = * val
260
+ return false
237
261
}),
238
262
})
239
263
},
@@ -256,16 +280,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
256
280
r .statusUpdater .Send (Update {
257
281
NamespacedName : key ,
258
282
Resource : new (egv1a1.ClientTrafficPolicy ),
259
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
283
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
260
284
t , ok := obj .(* egv1a1.ClientTrafficPolicy )
261
285
if ! ok {
262
286
err := fmt .Errorf ("unsupported object type %T" , obj )
263
287
errChan <- err
264
288
panic (err )
265
289
}
266
- tCopy := t .DeepCopy ()
267
- tCopy .Status = * val
268
- return tCopy
290
+
291
+ if isStatusEqual (t .Status , * val ) {
292
+ return true
293
+ }
294
+
295
+ t .Status = * val
296
+ return false
269
297
}),
270
298
})
271
299
},
@@ -288,16 +316,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
288
316
r .statusUpdater .Send (Update {
289
317
NamespacedName : key ,
290
318
Resource : new (egv1a1.BackendTrafficPolicy ),
291
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
319
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
292
320
t , ok := obj .(* egv1a1.BackendTrafficPolicy )
293
321
if ! ok {
294
322
err := fmt .Errorf ("unsupported object type %T" , obj )
295
323
errChan <- err
296
324
panic (err )
297
325
}
298
- tCopy := t .DeepCopy ()
299
- tCopy .Status = * val
300
- return tCopy
326
+
327
+ if isStatusEqual (t .Status , * val ) {
328
+ return true
329
+ }
330
+
331
+ t .Status = * val
332
+ return false
301
333
}),
302
334
})
303
335
},
@@ -320,16 +352,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
320
352
r .statusUpdater .Send (Update {
321
353
NamespacedName : key ,
322
354
Resource : new (egv1a1.SecurityPolicy ),
323
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
355
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
324
356
t , ok := obj .(* egv1a1.SecurityPolicy )
325
357
if ! ok {
326
358
err := fmt .Errorf ("unsupported object type %T" , obj )
327
359
errChan <- err
328
360
panic (err )
329
361
}
330
- tCopy := t .DeepCopy ()
331
- tCopy .Status = * val
332
- return tCopy
362
+
363
+ if isStatusEqual (t .Status , * val ) {
364
+ return true
365
+ }
366
+
367
+ t .Status = * val
368
+ return false
333
369
}),
334
370
})
335
371
},
@@ -350,16 +386,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
350
386
r .statusUpdater .Send (Update {
351
387
NamespacedName : key ,
352
388
Resource : new (gwapiv1a3.BackendTLSPolicy ),
353
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
389
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
354
390
t , ok := obj .(* gwapiv1a3.BackendTLSPolicy )
355
391
if ! ok {
356
392
err := fmt .Errorf ("unsupported object type %T" , obj )
357
393
errChan <- err
358
394
panic (err )
359
395
}
360
- tCopy := t .DeepCopy ()
361
- tCopy .Status = * val
362
- return tCopy
396
+
397
+ if isStatusEqual (t .Status , * val ) {
398
+ return true
399
+ }
400
+
401
+ t .Status = * val
402
+ return false
363
403
}),
364
404
})
365
405
},
@@ -382,16 +422,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
382
422
r .statusUpdater .Send (Update {
383
423
NamespacedName : key ,
384
424
Resource : new (egv1a1.EnvoyExtensionPolicy ),
385
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
425
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
386
426
t , ok := obj .(* egv1a1.EnvoyExtensionPolicy )
387
427
if ! ok {
388
428
err := fmt .Errorf ("unsupported object type %T" , obj )
389
429
errChan <- err
390
430
panic (err )
391
431
}
392
- tCopy := t .DeepCopy ()
393
- tCopy .Status = * val
394
- return tCopy
432
+
433
+ if isStatusEqual (t .Status , * val ) {
434
+ return true
435
+ }
436
+
437
+ t .Status = * val
438
+ return false
395
439
}),
396
440
})
397
441
},
@@ -414,16 +458,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
414
458
r .statusUpdater .Send (Update {
415
459
NamespacedName : key ,
416
460
Resource : new (egv1a1.Backend ),
417
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
461
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
418
462
t , ok := obj .(* egv1a1.Backend )
419
463
if ! ok {
420
464
err := fmt .Errorf ("unsupported object type %T" , obj )
421
465
errChan <- err
422
466
panic (err )
423
467
}
424
- tCopy := t .DeepCopy ()
425
- tCopy .Status = * val
426
- return tCopy
468
+
469
+ if isStatusEqual (t .Status , * val ) {
470
+ return true
471
+ }
472
+
473
+ t .Status = * val
474
+ return false
427
475
}),
428
476
})
429
477
},
@@ -450,16 +498,20 @@ func (r *gatewayAPIReconciler) subscribeAndUpdateStatus(ctx context.Context, ext
450
498
r .statusUpdater .Send (Update {
451
499
NamespacedName : key .NamespacedName ,
452
500
Resource : & obj ,
453
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
501
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
454
502
t , ok := obj .(* unstructured.Unstructured )
455
503
if ! ok {
456
504
err := fmt .Errorf ("unsupported object type %T" , obj )
457
505
errChan <- err
458
506
panic (err )
459
507
}
460
- tCopy := t .DeepCopy ()
461
- tCopy .Object ["status" ] = * val
462
- return tCopy
508
+
509
+ if isStatusEqual (t .Object ["status" ], * val ) {
510
+ return true
511
+ }
512
+
513
+ t .Object ["status" ] = * val
514
+ return false
463
515
}),
464
516
})
465
517
},
@@ -499,16 +551,22 @@ func (r *gatewayAPIReconciler) updateStatusForGateway(ctx context.Context, gtw *
499
551
r .statusUpdater .Send (Update {
500
552
NamespacedName : key ,
501
553
Resource : new (gwapiv1.Gateway ),
502
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
554
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
503
555
g , ok := obj .(* gwapiv1.Gateway )
504
556
if ! ok {
505
557
panic (fmt .Sprintf ("unsupported object type %T" , obj ))
506
558
}
507
- gCopy := g .DeepCopy ()
508
- gCopy .Status .Conditions = gtw .Status .Conditions
509
- gCopy .Status .Addresses = gtw .Status .Addresses
510
- gCopy .Status .Listeners = gtw .Status .Listeners
511
- return gCopy
559
+
560
+ if isStatusEqual (g .Status .Conditions , gtw .Status .Conditions ) &&
561
+ isStatusEqual (g .Status .Addresses , gtw .Status .Addresses ) &&
562
+ isStatusEqual (g .Status .Listeners , gtw .Status .Listeners ) {
563
+ return true
564
+ }
565
+
566
+ g .Status .Conditions = gtw .Status .Conditions
567
+ g .Status .Addresses = gtw .Status .Addresses
568
+ g .Status .Listeners = gtw .Status .Listeners
569
+ return false
512
570
}),
513
571
})
514
572
}
@@ -524,13 +582,19 @@ func (r *gatewayAPIReconciler) updateStatusForGatewayClass(
524
582
r .statusUpdater .Send (Update {
525
583
NamespacedName : types.NamespacedName {Name : gc .Name },
526
584
Resource : & gwapiv1.GatewayClass {},
527
- Mutator : MutatorFunc (func (obj client.Object ) client. Object {
585
+ Mutator : MutatorFunc (func (obj client.Object ) bool {
528
586
gc , ok := obj .(* gwapiv1.GatewayClass )
529
587
if ! ok {
530
588
panic (fmt .Sprintf ("unsupported object type %T" , obj ))
531
589
}
532
590
533
- return status .SetGatewayClassAccepted (gc .DeepCopy (), accepted , reason , msg )
591
+ gcp := status .SetGatewayClassAccepted (gc .DeepCopy (), accepted , reason , msg )
592
+ if isStatusEqual (gcp .Status , gc .Status ) {
593
+ return true
594
+ }
595
+
596
+ gc .Status = gcp .Status
597
+ return false
534
598
}),
535
599
})
536
600
} else {
0 commit comments