Skip to content

Commit

Permalink
fix: yurt-controller-manager reboot cannot remove taint node.openyurt…
Browse files Browse the repository at this point in the history
….io/unschedulable (#1233) (#1337)
  • Loading branch information
AndyEWang authored Mar 29, 2023
1 parent 5b4cfd8 commit 0896832
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type Controller struct {
leaseLister leaselisterv1.LeaseNamespaceLister
nodeUpdateQueue workqueue.Interface

ldc *utils.LeaseDelegatedCounter
ldc *utils.LeaseDelegatedCounter
delLdc *utils.LeaseDelegatedCounter
}

func (c *Controller) onLeaseCreate(n interface{}) {
Expand Down Expand Up @@ -87,6 +88,7 @@ func NewController(kc client.Interface, informerFactory informers.SharedInformer
client: kc,
nodeUpdateQueue: workqueue.NewNamed("poolcoordinator_node"),
ldc: utils.NewLeaseDelegatedCounter(),
delLdc: utils.NewLeaseDelegatedCounter(),
}

if informerFactory != nil {
Expand Down Expand Up @@ -152,6 +154,7 @@ func (c *Controller) doDeTaintNodeNotSchedulable(node *corev1.Node) *corev1.Node
taints := node.Spec.Taints
taints, deleted := utils.DeleteTaintsByKey(taints, constant.NodeNotSchedulableTaint)
if !deleted {
c.delLdc.Inc(node.Name)
klog.Infof("detaint %s: no key %s exists, nothing to do\n", node.Name, constant.NodeNotSchedulableTaint)
return node
}
Expand All @@ -162,6 +165,8 @@ func (c *Controller) doDeTaintNodeNotSchedulable(node *corev1.Node) *corev1.Node
nn, err = c.client.CoreV1().Nodes().Update(context.TODO(), nn, metav1.UpdateOptions{})
if err != nil {
klog.Error(err)
} else {
c.delLdc.Inc(node.Name)
}
}
return nn
Expand All @@ -186,9 +191,10 @@ func (c *Controller) syncHandler(key string) error {
c.ldc.Inc(nl.Name)
if c.ldc.Counter(nl.Name) >= constant.LeaseDelegationThreshold {
c.taintNodeNotSchedulable(nl.Name)
c.delLdc.Reset(nl.Name)
}
} else {
if c.ldc.Counter(nl.Name) >= constant.LeaseDelegationThreshold {
if c.delLdc.Counter(nl.Name) == 0 {
c.deTaintNodeNotSchedulable(nl.Name)
}
c.ldc.Reset(nl.Name)
Expand Down

0 comments on commit 0896832

Please sign in to comment.