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

DeletionTimestamp and Finalizer support in Mock server #3805

Closed
scrocquesel opened this issue Feb 6, 2022 · 3 comments · Fixed by #4801
Closed

DeletionTimestamp and Finalizer support in Mock server #3805

scrocquesel opened this issue Feb 6, 2022 · 3 comments · Fixed by #4801
Labels
component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly enhancement status/never-stale
Milestone

Comments

@scrocquesel
Copy link

Is your enhancement related to a problem? Please describe

I'm writing an operator and would like to test how it behaves when deleting a resource. In CRUD mode, when a resource is deleted, it is remove even if finalizers is not empty.

Describe the solution you'd like

I expect delete to update the resource with a deletionTimestamp if finalizers collection is not empty. When the operator will remove its finalizer and update the CR, if the finalizers collection is empty, the resource should be deleted.

I should be able to wait for the resource to be deleted (wait while get CR is not null) and assert the operator does its cleanup job.

Describe alternatives you've considered

I tried to update the resource with edit to set a deletionTimestamp but is seems to be not saved.

client.resources(CRD.class).inNamespace("foo").withName("bar").edit(p -> {
    p.getMetadata().setDeletionTimestamp("2022-02-06T14:21:44.719489Z");
    return p;
});

what works is to replace the CR.

var cr = client.resources(CRD.class).inNamespace("foo").withName("bar").get();
cr.getMetadata().setDeletionTimestamp("2022-02-06T14:21:44.719489Z");
client.resource(cr).createOrReplace();

Additional context

No response

@manusa manusa added component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly enhancement labels Feb 21, 2022
@amydentremont
Copy link

+1 on this, I was just writing a test and was surprised that my CR with a finalizer had actually been deleted

@stale
Copy link

stale bot commented Jun 29, 2022

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Jun 29, 2022
@stale stale bot closed this as completed Jul 7, 2022
@manusa manusa reopened this Jul 18, 2022
@derlin
Copy link

derlin commented Aug 23, 2022

Any news on this ? As Red Hat announced a Java Operator SDK preview, testing finalizers and dependent resources deletion will become a common use case: Write Kubernetes with the Java Operator SDK | Red Hat Developer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly enhancement status/never-stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants