Skip to content

Commit d59687c

Browse files
author
Will Daly
committed
kube-proxy: initialization wait for node and serviceCIDR synced
Follow-on from kubernetes#126532 to wait for pre-sync events delivered for the remaining two informers in kube-proxy (node and serviceCIDR).
1 parent 60c4c2b commit d59687c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pkg/proxy/config/config.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,10 @@ type NodeConfig struct {
300300
// NewNodeConfig creates a new NodeConfig.
301301
func NewNodeConfig(ctx context.Context, nodeInformer v1informers.NodeInformer, resyncPeriod time.Duration) *NodeConfig {
302302
result := &NodeConfig{
303-
listerSynced: nodeInformer.Informer().HasSynced,
304-
logger: klog.FromContext(ctx),
303+
logger: klog.FromContext(ctx),
305304
}
306305

307-
_, _ = nodeInformer.Informer().AddEventHandlerWithResyncPeriod(
306+
handlerRegistration, _ := nodeInformer.Informer().AddEventHandlerWithResyncPeriod(
308307
cache.ResourceEventHandlerFuncs{
309308
AddFunc: result.handleAddNode,
310309
UpdateFunc: result.handleUpdateNode,
@@ -313,6 +312,8 @@ func NewNodeConfig(ctx context.Context, nodeInformer v1informers.NodeInformer, r
313312
resyncPeriod,
314313
)
315314

315+
result.listerSynced = handlerRegistration.HasSynced
316+
316317
return result
317318
}
318319

@@ -403,12 +404,11 @@ type ServiceCIDRConfig struct {
403404
// NewServiceCIDRConfig creates a new ServiceCIDRConfig.
404405
func NewServiceCIDRConfig(ctx context.Context, serviceCIDRInformer networkingv1beta1informers.ServiceCIDRInformer, resyncPeriod time.Duration) *ServiceCIDRConfig {
405406
result := &ServiceCIDRConfig{
406-
listerSynced: serviceCIDRInformer.Informer().HasSynced,
407-
cidrs: sets.New[string](),
408-
logger: klog.FromContext(ctx),
407+
cidrs: sets.New[string](),
408+
logger: klog.FromContext(ctx),
409409
}
410410

411-
_, _ = serviceCIDRInformer.Informer().AddEventHandlerWithResyncPeriod(
411+
handlerRegistration, _ := serviceCIDRInformer.Informer().AddEventHandlerWithResyncPeriod(
412412
cache.ResourceEventHandlerFuncs{
413413
AddFunc: func(obj interface{}) {
414414
result.handleServiceCIDREvent(nil, obj)
@@ -422,6 +422,9 @@ func NewServiceCIDRConfig(ctx context.Context, serviceCIDRInformer networkingv1b
422422
},
423423
resyncPeriod,
424424
)
425+
426+
result.listerSynced = handlerRegistration.HasSynced
427+
425428
return result
426429
}
427430

0 commit comments

Comments
 (0)