mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #31578 from kevin-wangzefeng/add-retries-for-taints-e2e
Automatic merge from submit-queue add retries for add/update/remove taints on node in taints e2e fixes taint update conflict in taints e2e by adding retries for add/update/remove taints on node. ref #27655 and #31066
This commit is contained in:
commit
6dd8b975cb
@ -2851,6 +2851,7 @@ func RemoveLabelOffNode(c *client.Client, nodeName string, labelKey string) {
|
||||
}
|
||||
|
||||
func AddOrUpdateTaintOnNode(c *client.Client, nodeName string, taint api.Taint) {
|
||||
for attempt := 0; attempt < UpdateRetries; attempt++ {
|
||||
node, err := c.Nodes().Get(nodeName)
|
||||
ExpectNoError(err)
|
||||
|
||||
@ -2881,7 +2882,17 @@ func AddOrUpdateTaintOnNode(c *client.Client, nodeName string, taint api.Taint)
|
||||
}
|
||||
node.Annotations[api.TaintsAnnotationKey] = string(taintsData)
|
||||
_, err = c.Nodes().Update(node)
|
||||
if err != nil {
|
||||
if !apierrs.IsConflict(err) {
|
||||
ExpectNoError(err)
|
||||
} else {
|
||||
Logf("Conflict when trying to add/update taint %v to %v", taint, nodeName)
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func taintExists(taints []api.Taint, taintKey string) bool {
|
||||
@ -2927,6 +2938,7 @@ func deleteTaintByKey(taints []api.Taint, taintKey string) ([]api.Taint, error)
|
||||
// won't fail if target taint doesn't exist or has been removed.
|
||||
func RemoveTaintOffNode(c *client.Client, nodeName string, taintKey string) {
|
||||
By("removing the taint " + taintKey + " off the node " + nodeName)
|
||||
for attempt := 0; attempt < UpdateRetries; attempt++ {
|
||||
node, err := c.Nodes().Get(nodeName)
|
||||
ExpectNoError(err)
|
||||
|
||||
@ -2946,9 +2958,21 @@ func RemoveTaintOffNode(c *client.Client, nodeName string, taintKey string) {
|
||||
taintsData, err := json.Marshal(newTaints)
|
||||
ExpectNoError(err)
|
||||
node.Annotations[api.TaintsAnnotationKey] = string(taintsData)
|
||||
nodeUpdated, err := c.Nodes().Update(node)
|
||||
_, err = c.Nodes().Update(node)
|
||||
if err != nil {
|
||||
if !apierrs.IsConflict(err) {
|
||||
ExpectNoError(err)
|
||||
} else {
|
||||
Logf("Conflict when trying to add/update taint %v to %v", taintKey, nodeName)
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
nodeUpdated, err := c.Nodes().Get(nodeName)
|
||||
ExpectNoError(err)
|
||||
By("verifying the node doesn't have the taint " + taintKey)
|
||||
taintsGot, err := api.GetTaintsFromNodeAnnotations(nodeUpdated.Annotations)
|
||||
ExpectNoError(err)
|
||||
|
Loading…
Reference in New Issue
Block a user