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

object doesn't get updated after fakeClient.Delete(object) #3059

Open
Nihileon opened this issue Jan 3, 2025 · 5 comments · May be fixed by #3063
Open

object doesn't get updated after fakeClient.Delete(object) #3059

Nihileon opened this issue Jan 3, 2025 · 5 comments · May be fixed by #3063
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Nihileon
Copy link

Nihileon commented Jan 3, 2025

fakeClient.Delete(obj) doesn't update deletionTimestamp of the obj passed to the function. The bug is in fakeClient.deleteObject, since it gets a new object and updates the new object without rewriting the original object.

Reference: https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.0/pkg/client/fake/client.go#L1085-L1095

@Nihileon Nihileon changed the title Object doesn't get updated after fakeClient.Delete object doesn't get updated after fakeClient.Delete(object) Jan 3, 2025
@alvaroaleman alvaroaleman added the kind/bug Categorizes issue or PR as related to a bug. label Jan 7, 2025
@sbueringer
Copy link
Member

I assume the regular client updates it? (I think I remember that the regular client also doesn't update it, but I'm not sure)

@alvaroaleman
Copy link
Member

Actually it looks like it doesn't:

Body(deleteOpts.AsDeleteOptions()).

So after someone deletes an object, their in-mem representation doesn't reflect that? That is different from all other methods and very confusing

@sbueringer
Copy link
Member

Yeah. I think I noticed this 1-2 months ago in a unit test. First I thought the fake client is the problem but then I saw that the real client has the same behavior :)

@troy0820
Copy link
Member

troy0820 commented Jan 8, 2025

I can take this one if you all don't mind.

/assign @troy0820

@sbueringer
Copy link
Member

I'm wondering if there are comparable cases in client-go and how they are handled there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants