Skip to content

Commit a7ecb66

Browse files
authored
Merge pull request #1012 from priyapande/master
Fix MultiNetwork CRD Cache Sync for Network Informer Factory
2 parents 15504c7 + b165160 commit a7ecb66

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

cmd/cloud-controller-manager/nodeipamcontroller.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ func startNodeIpamController(ccmConfig *cloudcontrollerconfig.CompletedConfig, n
7070
nwInformer := nwInfFactory.Networking().V1().Networks()
7171
gnpInformer := nwInfFactory.Networking().V1().GKENetworkParamSets()
7272

73-
// TODO: Add a flag to control to start this informer specific to required GKE functionality
74-
go nwInfFactory.Start(ctx.Stop)
75-
76-
return nodeipamcontroller.StartNodeIpamController(
73+
ctrl, started, err := nodeipamcontroller.StartNodeIpamController(
7774
wait.ContextForChannel(ctx.Stop),
7875
ccmConfig.SharedInformers.Core().V1().Nodes(),
7976
ccmConfig.ClientBuilder.ClientOrDie("node-controller"),
@@ -89,4 +86,13 @@ func startNodeIpamController(ccmConfig *cloudcontrollerconfig.CompletedConfig, n
8986
ipam.CIDRAllocatorType(ccmConfig.ComponentConfig.KubeCloudShared.CIDRAllocatorType),
9087
ctx.ControllerManagerMetrics,
9188
)
89+
90+
if err != nil {
91+
return nil, false, err
92+
}
93+
94+
// TODO: Add a flag to control to start this informer specific to required GKE functionality
95+
go nwInfFactory.Start(ctx.Stop)
96+
97+
return ctrl, started, nil
9298
}

pkg/controller/nodeipam/ipam/cloud_cidr_allocator.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ type cloudCIDRAllocator struct {
9595
// NewCloudCIDRAllocator.
9696
nodeLister corelisters.NodeLister
9797
// nodesSynced returns true if the node shared informer has been synced at least once.
98-
nodesSynced cache.InformerSynced
98+
nodesSynced cache.InformerSynced
99+
networksSynced cache.InformerSynced
100+
gnpsSynced cache.InformerSynced
99101

100102
recorder record.EventRecorder
101103
queue workqueue.RateLimitingInterface
@@ -147,6 +149,8 @@ func NewCloudCIDRAllocator(client clientset.Interface, cloud cloudprovider.Inter
147149
gnpLister: gnpInformer.Lister(),
148150
nodeLister: nodeInformer.Lister(),
149151
nodesSynced: nodeInformer.Informer().HasSynced,
152+
networksSynced: nwInformer.Informer().HasSynced,
153+
gnpsSynced: gnpInformer.Informer().HasSynced,
150154
recorder: recorder,
151155
queue: workqueue.NewRateLimitingQueueWithConfig(workqueue.DefaultControllerRateLimiter(), workqueue.RateLimitingQueueConfig{Name: workqueueName}),
152156
stackType: stackType,
@@ -289,7 +293,12 @@ func (ca *cloudCIDRAllocator) Run(stopCh <-chan struct{}) {
289293
klog.Infof("Starting cloud CIDR allocator")
290294
defer klog.Infof("Shutting down cloud CIDR allocator")
291295

292-
if !cache.WaitForNamedCacheSync("cidrallocator", stopCh, ca.nodesSynced) {
296+
syncFuncs := []cache.InformerSynced{ca.nodesSynced}
297+
if ca.enableMultiNetworking {
298+
syncFuncs = append(syncFuncs, ca.networksSynced, ca.gnpsSynced)
299+
}
300+
301+
if !cache.WaitForNamedCacheSync("cidrallocator", stopCh, syncFuncs...) {
293302
return
294303
}
295304

0 commit comments

Comments
 (0)