You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FakeClient update on status subresource not returning error despite conflicting resource version since v0.15.0 #2362
After upgrading to controller-runtime 0.15.0 one of our unit tests started failing.
The tested controller performs a client.Status().Update(...) on Pod resources. The now failing unit test aims to test the controller behavior in case of a resource conflict (i.e. The fake client has a pod object, the controller performs a status update on the same pod object, but with a different resource version -> expected behavior: Conflict error, actual behavior since upgrading to 0.15.0: no error).
This can be reproduced with the following testcase: (controller-runtime 0.15.0, k8s api 0.27.2)
changed the title [-]FakeClient update on status subresource not returning error despite conflicting resource version[/-][+]FakeClient update on status subresource not returning error despite conflicting resource version since 0.15.0[/+]on May 30, 2023
changed the title [-]FakeClient update on status subresource not returning error despite conflicting resource version since 0.15.0[/-][+]FakeClient update on status subresource not returning error despite conflicting resource version since v0.15.0[/+]on May 30, 2023
While I'm waiting for a fix to be released, I rolled back my controller-runtime to use 0.14.6 (with all k8s go libs using 0.26.1) and it works for now...
Reacted by Stefan Büringer, Andrii Soldatenko and Michael Filanov
Generating the client and adding a resource with client.Create() does not work as before.
All tests return a status not found since the object is not added to the StatusSubresource.
With the release of v0.16.0 did this not work? I see above that the #2365 wasn't successful but wanted to know if anything else in that release fixed this issue.
Is there another workaround for this? my test is trying to check a status change on a reconcile, meaning i cannot provide WithStatusSubresource when creating the client because this is what the test need to validate.
I saw that update just update everything including the status but it's a bad solution because a real client doesn't behave that way.
Is there a workaround? or another client that i can use?
I was thinking maybe wrap the client and override the Status().Update() function to call Update in the tests but it sounds like a fix to the fake client would be better.
In older versions (0.13.x) it worked as expected why did that flow changed?
The original issue was fixed and the latter discussion seems to evolve around the question of how to configure a CRD to have a status subresource in the fake client. The tl,dr on how to configure the fakeclient to provide a status subresource for a given resource is to do the following:
If this is needed or not can not be automatically inferred, refer to #2386 (comment) as for why.
As the original issue was fixed, I am going to close this. Please limit discussions on this issue to the bug it was created for and that was since fixed.
Reacted by Stefan Büringer, Semih Buyukgungor, Kumar Mallikarjuna, Ivan Mukhin and Hongkai Liu
Activity
[-]FakeClient update on status subresource not returning error despite conflicting resource version[/-][+]FakeClient update on status subresource not returning error despite conflicting resource version since 0.15.0[/+][-]FakeClient update on status subresource not returning error despite conflicting resource version since 0.15.0[/-][+]FakeClient update on status subresource not returning error despite conflicting resource version since v0.15.0[/+]sbueringer commentedon May 31, 2023
Agree, sounds like a bug
🐛 `fakeClient.Status().Update(...)` cannot recognize resource version
iiiceoo commentedon May 31, 2023
/assign
🐛 `fakeClient.Status().Update(...)` cannot recognize resource version
🐛 fakeClient.Status().Update(...) cannot recognize resource version
AmFlint commentedon Jun 23, 2023
Hello, I encountered the exact same issue.
While I'm waiting for a fix to be released, I rolled back my controller-runtime to use 0.14.6 (with all k8s go libs using 0.26.1) and it works for now...
sbueringer commentedon Jul 1, 2023
@AmFlint Did the fix implemented in #2365 work for you?
RealAnna commentedon Jul 12, 2023
@sbueringer this did not work entirely for us. With the new changes we still had to explicitly add our crds as Statussubresurce to be able to use status updates.
https://github.com/keptn/lifecycle-toolkit/pull/1701/files#diff-a1bebf6a5efdcbe0c8bd59ac1387c9d1f80f42781e1dc463cdc121222dafa089R17
Generating the client and adding a resource with client.Create() does not work as before.
All tests return a status not found since the object is not added to the StatusSubresource.
austincunningham commentedon Jul 14, 2023
Same issue using #2365 didn't fix the issue
troy0820 commentedon Aug 25, 2023
/kind bug
With the release of v0.16.0 did this not work? I see above that the #2365 wasn't successful but wanted to know if anything else in that release fixed this issue.
troy0820 commentedon Aug 29, 2023
Re-doing this test like this:
now passes with the intended error as before.
The snippet was updated here
Doing a subsequent Get of the pod will show that the pod is not updated with no
status.PhaseandresourceVersionof 1.This test is running against controller-runtime v0.16.0 and go1.20
Does this help @nbam-e ?
3 remaining items
fix test, see: kubernetes-sigs/controller-runtime#2362 (comment)
Upgrade operator utils (#587)
test: pass WithStatusSubresource to the fake client
test: pass WithStatusSubresource to the fake client
test: pass WithStatusSubresource to the fake client
test: pass WithStatusSubresource to the fake client
ericabramov commentedon Nov 16, 2023
I've came up with a hacky workaround that solved the gap for me
A POC code is posted in this stackoverflow thread
https://stackoverflow.com/questions/77489441/go-k8s-controller-runtime-upgrade-fake-client-lacks-functionality
filanov commentedon Nov 19, 2023
Is there another workaround for this? my test is trying to check a status change on a reconcile, meaning i cannot provide
WithStatusSubresourcewhen creating the client because this is what the test need to validate.I saw that update just update everything including the status but it's a bad solution because a real client doesn't behave that way.
Is there a workaround? or another client that i can use?
I was thinking maybe wrap the client and override the
Status().Update()function to call Update in the tests but it sounds like a fix to the fake client would be better.In older versions (0.13.x) it worked as expected why did that flow changed?
alvaroaleman commentedon Dec 2, 2023
The original issue was fixed and the latter discussion seems to evolve around the question of how to configure a CRD to have a status subresource in the fake client. The tl,dr on how to configure the fakeclient to provide a status subresource for a given resource is to do the following:
If this is needed or not can not be automatically inferred, refer to #2386 (comment) as for why.
As the original issue was fixed, I am going to close this. Please limit discussions on this issue to the bug it was created for and that was since fixed.
fix(appset): Retry on conflict when updating status
fix(appset): Retry on conflict when updating status
fix(appset): Retry on conflict when updating status (#19663)
chore: argo cd 2.13.2 (#369)
fix(test): fix unit tests not working after controller-runtime update…