kube-proxy: initialization wait for node and serviceCIDR synced

Follow-on from https://github.com/kubernetes/kubernetes/pull/126532
to wait for pre-sync events delivered for the remaining two informers
in kube-proxy (node and serviceCIDR).
This commit is contained in:
Will Daly 2024-08-06 09:01:42 -07:00
parent 60c4c2b252
commit d59687c367

View File

@ -300,11 +300,10 @@ type NodeConfig struct {
// NewNodeConfig creates a new NodeConfig.
func NewNodeConfig(ctx context.Context, nodeInformer v1informers.NodeInformer, resyncPeriod time.Duration) *NodeConfig {
result := &NodeConfig{
listerSynced: nodeInformer.Informer().HasSynced,
logger: klog.FromContext(ctx),
}
_, _ = nodeInformer.Informer().AddEventHandlerWithResyncPeriod(
handlerRegistration, _ := nodeInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: result.handleAddNode,
UpdateFunc: result.handleUpdateNode,
@ -313,6 +312,8 @@ func NewNodeConfig(ctx context.Context, nodeInformer v1informers.NodeInformer, r
resyncPeriod,
)
result.listerSynced = handlerRegistration.HasSynced
return result
}
@ -403,12 +404,11 @@ type ServiceCIDRConfig struct {
// NewServiceCIDRConfig creates a new ServiceCIDRConfig.
func NewServiceCIDRConfig(ctx context.Context, serviceCIDRInformer networkingv1beta1informers.ServiceCIDRInformer, resyncPeriod time.Duration) *ServiceCIDRConfig {
result := &ServiceCIDRConfig{
listerSynced: serviceCIDRInformer.Informer().HasSynced,
cidrs: sets.New[string](),
logger: klog.FromContext(ctx),
}
_, _ = serviceCIDRInformer.Informer().AddEventHandlerWithResyncPeriod(
handlerRegistration, _ := serviceCIDRInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
result.handleServiceCIDREvent(nil, obj)
@ -422,6 +422,9 @@ func NewServiceCIDRConfig(ctx context.Context, serviceCIDRInformer networkingv1b
},
resyncPeriod,
)
result.listerSynced = handlerRegistration.HasSynced
return result
}