Skip to content

Commit 2c5fbc6

Browse files
committed
add retry to update node label
fixing: ``` [FAILED] Unexpected error: <*errors.StatusError | 0xc000788780>: Operation cannot be fulfilled on nodes "worker-0": the object has been modified; please apply your changes to the latest version and try again { ErrStatus: { TypeMeta: {Kind: "", APIVersion: ""}, ListMeta: { SelfLink: "", ResourceVersion: "", Continue: "", RemainingItemCount: nil, }, Status: "Failure", Message: "Operation cannot be fulfilled on nodes \"worker-0\": the object has been modified; please apply your changes to the latest version and try again", Reason: "Conflict", Details: {Name: "worker-0", Group: "", Kind: "nodes", UID: "", Causes: nil, RetryAfterSeconds: 0}, Code: 409, }, } ``` Signed-off-by: Sebastian Sch <[email protected]>
1 parent cf7573b commit 2c5fbc6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/conformance/tests/test_sriov_operator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
"k8s.io/apimachinery/pkg/fields"
2424
"k8s.io/apimachinery/pkg/labels"
25-
"k8s.io/utils/pointer"
25+
"k8s.io/apimachinery/pkg/types"
26+
"k8s.io/utils/ptr"
2627
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
2728

2829
sriovv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
@@ -90,10 +91,10 @@ var _ = Describe("[sriov] operator", Ordered, func() {
9091
Expect(err).ToNot(HaveOccurred())
9192

9293
Expect(len(selectedNodes)).To(BeNumerically(">", 0), "There must be at least one worker")
93-
candidate := selectedNodes[0]
94-
candidate.Labels["sriovenabled"] = "true"
95-
_, err = clients.CoreV1Interface.Nodes().Update(context.Background(), &candidate, metav1.UpdateOptions{})
94+
patch := []byte(`{"metadata":{"labels":{"sriovenabled":"true"}}}`)
95+
candidate, err := clients.CoreV1Interface.Nodes().Patch(context.Background(), selectedNodes[0].Name, types.StrategicMergePatchType, patch, metav1.PatchOptions{})
9696
Expect(err).ToNot(HaveOccurred())
97+
selectedNodes[0] = *candidate
9798

9899
By("Setting the node selector for each daemon")
99100
cfg := sriovv1.SriovOperatorConfig{}
@@ -468,7 +469,7 @@ var _ = Describe("[sriov] operator", Ordered, func() {
468469
}
469470

470471
err = clients.Pods(namespaces.Test).Delete(context.Background(), podObj.Name, metav1.DeleteOptions{
471-
GracePeriodSeconds: pointer.Int64Ptr(0)})
472+
GracePeriodSeconds: ptr.To(int64(0))})
472473
Expect(err).ToNot(HaveOccurred())
473474

474475
return found
@@ -953,8 +954,7 @@ var _ = Describe("[sriov] operator", Ordered, func() {
953954
}, 2*time.Minute, 10*time.Second).Should(BeTrue(), "Error to detect Required Event")
954955
By("Delete first pod and release all VFs")
955956
err = clients.Pods(namespaces.Test).Delete(context.Background(), runningPodA.Name, metav1.DeleteOptions{
956-
GracePeriodSeconds: pointer.Int64Ptr(0),
957-
})
957+
GracePeriodSeconds: ptr.To(int64(0))})
958958
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error to delete pod %s", runningPodA.Name))
959959
By("Checking that second pod is able to use released VF")
960960
waitForPodRunning(runningPodB)

0 commit comments

Comments
 (0)