tests, infra-test, Fix node updates
The RetryOnConflict should have a refetch of the state,
so in case of a conflict error, only the custom changes
would be applied.
@@ -228,8 +228,14 @@ var _ = Describe("[Serial]Infrastructure", func() {
AfterEach(func() {
if selectedNode != nil {
By("removing the taint from the tainted node")
- var taints []k8sv1.Taint
+ err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
+ var err error
+ selectedNode, err = virtClient.CoreV1().Nodes().Get(selectedNode.Name, metav1.GetOptions{})
+ if err != nil {
+ return err
+ }
+ var taints []k8sv1.Taint
for _, taint := range selectedNode.Spec.Taints {
if taint.Key != "CriticalAddonsOnly" {
taints = append(taints, taint)
@@ -240,8 +246,7 @@ var _ = Describe("[Serial]Infrastructure", func() {
nodeCopy.ResourceVersion = ""
nodeCopy.Spec.Taints = taints
- err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
- _, err := virtClient.CoreV1().Nodes().Update(nodeCopy)
+ _, err = virtClient.CoreV1().Nodes().Update(nodeCopy)
return err
})
Expect(err).ShouldNot(HaveOccurred())
@@ -310,6 +315,13 @@ var _ = Describe("[Serial]Infrastructure", func() {
go signalTerminatedPods(stopCn, lw.ResultChan(), terminatedPodsCn)
By("tainting the selected node")
+ err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
+ var err error
+ selectedNode, err = virtClient.CoreV1().Nodes().Get(selectedNode.Name, metav1.GetOptions{})
+ if err != nil {
+ return err
+ }
+
selectedNodeCopy := selectedNode.DeepCopy()
selectedNodeCopy.Spec.Taints = append(selectedNodeCopy.Spec.Taints, k8sv1.Taint{
Key: "CriticalAddonsOnly",
@@ -317,8 +329,7 @@ var _ = Describe("[Serial]Infrastructure", func() {
Effect: k8sv1.TaintEffectNoExecute,
})
- err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
- _, err := virtClient.CoreV1().Nodes().Update(selectedNodeCopy)
+ _, err = virtClient.CoreV1().Nodes().Update(selectedNodeCopy)
return err
})
Expect(err).ShouldNot(HaveOccurred())
