-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
The fake client.Update() updates the status fields #2478
Comments
This seems to replicate the behavior in issue #2474 but the other way around. It seems to me that the fake client is copying over everything and not discarding the status when going through the update chain. PR I have for that #2479 solves that case however long term we may need to decouple the methods that the fakeclient uses. |
For whatever reason, the test case that's supposed to catch this acts differently on different fields of corev1.Node.Status. I'll debug further, but this patch to the test shows the bug:
|
I think here's where the problem is: fake client uses json marshaling/unmarshaling under the covers to assign the However, while unmarshaling oldObject's status back into newObject passed to controller-runtime/pkg/client/fake/client.go Lines 1036 to 1038 in 2a553d6
|
In this pr #2479 I created a test to show that the other values do not get overwritten when updating the status. So it ends up being like this: (status update)
So it’ll only see the difference in the status when doing the update. |
There was a reason we have to serialize it like that if I’m not mistaken. |
/assign The root of the issue is the go json unmarshaller not zeroing the target, as a result, if the status is empty and the new status is not-empty, the non-empty status remains. This is also why the test didn't catch this, as it doesn't test with an empty status. I'll file a fix. |
I'm observing that using the non-subresource
fake.Client
on both in-tree types (like corev1.Node or corev1.Pod) as well as Custom Resources actually save modifications onstatus
fields to the resource (and are reflected on subsequentGet
calls).A minimal repro: https://gist.github.com/ahmetb/50784526a54244d45022a7ed8d556a62
This is the case even if I do
fake.NewClientBuilder().WithStatusSubresource(&corev1.Pod{})
Expected behavior is to be the same as a non-fake client where if you modify a
status
field and useclient.Update(ctx, obj)
the modifications on thestatus
field are discarded./kind bug
The text was updated successfully, but these errors were encountered: