Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.15] 🐛 fakeClient.Status().Update(...) cannot recognize resource version conflicts #2372

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/client/fake/client.go
Expand Up @@ -992,11 +992,11 @@ func copyNonStatusFrom(old, new runtime.Object) error {
}
}

newClientObject.SetResourceVersion(rv)

if err := fromMapStringAny(newMapStringAny, new); err != nil {
return fmt.Errorf("failed to convert back from map[string]any: %w", err)
}
newClientObject.SetResourceVersion(rv)

return nil
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/client/fake/client_test.go
Expand Up @@ -1431,14 +1431,15 @@ var _ = Describe("Fake client", func() {
It("should return a conflict error when an incorrect RV is used on status update", func() {
obj := &corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node",
Name: "node",
ResourceVersion: trackerAddResourceVersion,
},
}
cl := NewClientBuilder().WithStatusSubresource(obj).WithObjects(obj).Build()

obj.Status.Phase = corev1.NodeRunning
obj.ResourceVersion = "invalid"
err := cl.Update(context.Background(), obj)
err := cl.Status().Update(context.Background(), obj)
Expect(apierrors.IsConflict(err)).To(BeTrue())
})

Expand Down