@@ -152,8 +152,11 @@ func (k *K8s) EventService(ns *Namespace, data *Service) (updateRequired bool) {
152
152
newService := data
153
153
oldService , ok := ns .Services [data .Name ]
154
154
if ! ok {
155
- // intentionally do not add it. TODO see if our idea of only watching is ok
155
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
156
+ // We should treat it as a CREATE.
156
157
logger .Warningf ("Service '%s' not registered with controller !" , data .Name )
158
+ data .Status = ADDED
159
+ return k .EventService (ns , data )
157
160
}
158
161
if oldService .Equal (newService ) {
159
162
return updateRequired
@@ -235,9 +238,11 @@ func (k *K8s) EventSecret(ns *Namespace, data *Secret) (updateRequired bool) {
235
238
newSecret := data
236
239
oldSecret , ok := ns .Secret [data .Name ]
237
240
if ! ok {
238
- // intentionally do not add it. TODO see if our idea of only watching is ok
241
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
242
+ // We should treat it as a CREATE.
239
243
logger .Warningf ("Secret '%s' not registered with controller !" , data .Name )
240
- return updateRequired
244
+ data .Status = ADDED
245
+ return k .EventSecret (ns , data )
241
246
}
242
247
if oldSecret .Equal (data ) {
243
248
return updateRequired
@@ -325,8 +330,11 @@ func (k *K8s) EventPublishService(ns *Namespace, data *Service) (updateRequired
325
330
newService := data
326
331
oldService , ok := ns .Services [data .Name ]
327
332
if ! ok {
328
- // intentionally do not add it. TODO see if our idea of only watching is ok
333
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
334
+ // We should treat it as a CREATE.
329
335
logger .Warningf ("Service '%s' not registered with controller !" , data .Name )
336
+ data .Status = ADDED
337
+ return k .EventPublishService (ns , data )
330
338
}
331
339
if oldService .EqualWithAddresses (newService ) {
332
340
return
@@ -381,7 +389,11 @@ func (k *K8s) EventGatewayClass(data *GatewayClass) (updateRequired bool) {
381
389
newGatewayClass := data
382
390
oldGatewayClass , ok := k .GatewayClasses [data .Name ]
383
391
if ! ok {
392
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
393
+ // We should treat it as a CREATE.
384
394
logger .Warningf ("Modification of unexisting gatewayclass %s" , data .Name )
395
+ data .Status = ADDED
396
+ return k .EventGatewayClass (data )
385
397
}
386
398
if ok && oldGatewayClass .Generation == newGatewayClass .Generation ||
387
399
newGatewayClass .Equal (oldGatewayClass ) {
@@ -412,7 +424,11 @@ func (k *K8s) EventGateway(ns *Namespace, data *Gateway) (updateRequired bool) {
412
424
newGateway := data
413
425
oldGateway , ok := ns .Gateways [data .Name ]
414
426
if ! ok {
427
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
428
+ // We should treat it as a CREATE.
415
429
logger .Warningf ("Modification of unexisting gateway %s" , data .Name )
430
+ data .Status = ADDED
431
+ return k .EventGateway (ns , data )
416
432
}
417
433
if ok && newGateway .Generation == oldGateway .Generation ||
418
434
newGateway .Equal (oldGateway ) {
@@ -444,7 +460,11 @@ func (k *K8s) EventTCPRoute(ns *Namespace, data *TCPRoute) (updateRequired bool)
444
460
newTCPRoute := data
445
461
oldTCPRoute , ok := ns .TCPRoutes [data .Name ]
446
462
if ! ok {
463
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
464
+ // We should treat it as a CREATE.
447
465
logger .Warningf ("Modification of unexisting tcproute %s" , data .Name )
466
+ data .Status = ADDED
467
+ return k .EventTCPRoute (ns , data )
448
468
}
449
469
if ok && newTCPRoute .Generation == oldTCPRoute .Generation ||
450
470
newTCPRoute .Equal (oldTCPRoute ) {
@@ -475,8 +495,11 @@ func (k *K8s) EventReferenceGrant(ns *Namespace, data *ReferenceGrant) (updateRe
475
495
newReferenceGrant := data
476
496
oldReferenceGrant , ok := ns .ReferenceGrants [data .Name ]
477
497
if ! ok {
498
+ // It can happen (resync) that we receive an UPDATE on a item that is not yet registered
499
+ // We should treat it as a CREATE.
478
500
logger .Warningf ("Modification of unexisting referencegrant %s" , data .Name )
479
- return
501
+ data .Status = ADDED
502
+ return k .EventReferenceGrant (ns , data )
480
503
}
481
504
if ok && newReferenceGrant .Generation == oldReferenceGrant .Generation ||
482
505
newReferenceGrant .Equal (oldReferenceGrant ) {
0 commit comments