mirror of https://github.com/k3s-io/k3s
Merge pull request #59887 from dims/process-cloud-nodes-in-ccm-before-creating-shared-informer-handler
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Process existing cloud nodes in CCM **What this PR does / why we need it**: This is a timing issue. If kubelet(s) get started before the CCM is started, the shared informer event handler does not process them at all. So we should loop through these before. We run this in a go wait.Until loop to tolerate errors when listing the nodes and giving an opportunity for any scripts that may need to setup RBAC roles etc. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #58613 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/6/head
commit
01517e530f
|
@ -105,8 +105,11 @@ func NewCloudNodeController(
|
|||
nodeStatusUpdateFrequency: nodeStatusUpdateFrequency,
|
||||
}
|
||||
|
||||
nodeInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: cnc.AddCloudNode,
|
||||
// Use shared informer to listen to add/update of nodes. Note that any nodes
|
||||
// that exist before node controller starts will show up in the update method
|
||||
cnc.nodeInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: cnc.AddCloudNode,
|
||||
UpdateFunc: cnc.UpdateCloudNode,
|
||||
})
|
||||
|
||||
return cnc
|
||||
|
@ -309,6 +312,14 @@ func (cnc *CloudNodeController) MonitorNode() {
|
|||
}
|
||||
}
|
||||
|
||||
func (cnc *CloudNodeController) UpdateCloudNode(_, newObj interface{}) {
|
||||
if _, ok := newObj.(*v1.Node); !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", newObj))
|
||||
return
|
||||
}
|
||||
cnc.AddCloudNode(newObj)
|
||||
}
|
||||
|
||||
// This processes nodes that were added into the cluster, and cloud initialize them if appropriate
|
||||
func (cnc *CloudNodeController) AddCloudNode(obj interface{}) {
|
||||
node := obj.(*v1.Node)
|
||||
|
|
Loading…
Reference in New Issue