Use NC to fix deprecated taint key name
This commit is contained in:
@@ -404,6 +404,17 @@ func NewNodeController(
|
||||
})
|
||||
}
|
||||
|
||||
// NOTE(resouer): nodeInformer to substitute deprecated taint key (notReady -> not-ready).
|
||||
// Remove this logic when we don't need this backwards compatibility
|
||||
nodeInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: util.CreateAddNodeHandler(func(node *v1.Node) error {
|
||||
return nc.doFixDeprecatedTaintKeyPass(node)
|
||||
}),
|
||||
UpdateFunc: util.CreateUpdateNodeHandler(func(_, newNode *v1.Node) error {
|
||||
return nc.doFixDeprecatedTaintKeyPass(newNode)
|
||||
}),
|
||||
})
|
||||
|
||||
nc.nodeLister = nodeInformer.Lister()
|
||||
nc.nodeInformerSynced = nodeInformer.Informer().HasSynced
|
||||
|
||||
@@ -442,6 +453,38 @@ func (nc *Controller) doEvictionPass() {
|
||||
}
|
||||
}
|
||||
|
||||
// doFixDeprecatedTaintKeyPass checks and replaces deprecated taint key with proper key name if needed.
|
||||
func (nc *Controller) doFixDeprecatedTaintKeyPass(node *v1.Node) error {
|
||||
taintsToAdd := []*v1.Taint{}
|
||||
taintsToDel := []*v1.Taint{}
|
||||
|
||||
for _, taint := range node.Spec.Taints {
|
||||
if taint.Key == algorithm.DeprecatedTaintNodeNotReady {
|
||||
// delete old taint
|
||||
tDel := taint
|
||||
taintsToDel = append(taintsToDel, &tDel)
|
||||
|
||||
// add right taint
|
||||
tAdd := taint
|
||||
tAdd.Key = algorithm.TaintNodeNotReady
|
||||
taintsToAdd = append(taintsToAdd, &tAdd)
|
||||
|
||||
glog.Warningf("Detected deprecated taint key: %v on node: %v, will substitute it with %v",
|
||||
algorithm.DeprecatedTaintNodeNotReady, node.GetName(), algorithm.TaintNodeNotReady)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(taintsToAdd) == 0 && len(taintsToDel) == 0 {
|
||||
return nil
|
||||
}
|
||||
if !util.SwapNodeControllerTaint(nc.kubeClient, taintsToAdd, taintsToDel, node) {
|
||||
return fmt.Errorf("failed to swap taints of node %+v", node)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nc *Controller) doNoScheduleTaintingPass(node *v1.Node) error {
|
||||
// Map node's condition to Taints.
|
||||
taints := []v1.Taint{}
|
||||
|
||||
Reference in New Issue
Block a user