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

Support cascading delete on custom resources #1041

rimesc opened this issue Mar 21, 2018 · 4 comments

Support cascading delete on custom resources #1041

rimesc opened this issue Mar 21, 2018 · 4 comments


Copy link

@rimesc rimesc commented Mar 21, 2018

The interface returned by KubernetesClient.customResources(...) doesn't provide a method to set cascading=true.

The object itself (an instance of CustomResourcesOperationsImpl) does have a cascading flag, and a constructor that allows it to be specified, but it's defaulted to false in the only constructor that's actually used.

As a work around, you can construct an instance yourself using the constructor that does have the relevant parameter, but it would be helpful if the interface had a method for setting it, as other resource types do. It's worth noting that while technically the object does have a method for setting cascading=true that it inherits from the base class, casting to the base class and calling the method explodes because it uses reflection to find a suitable constructor and no such constructor exists in this case.

In particular, this makes it difficult to delete Argo workflows and their underlying pods.

Copy link

@Nighthawk22 Nighthawk22 commented Apr 25, 2018

Any idea how to work around the issue?

@rohanKanojia rohanKanojia self-assigned this May 9, 2019
Copy link

@rohanKanojia rohanKanojia commented May 17, 2019

@rimesc : Hi, Are you talking about Custom Resource Definition (CRDs) or Custom Resources(CRs). I looked into CustomResourceOperationsImpl and CustomResourceDefinitionOperationsImpl but I could not find the cascading flag you talked about.

We do have cascade deletion of replica sets before deleting deployment. But we do that on our own. So how cascading delete on Custom Resources would work? One thing could be deleting all the Custom Resources(CRs) before deleting Custom Resource Definition (CRDs). Or would cascade deletion's behavior would change depending upon Custom Resource Definition (CRDs)? Do you know how kubectl handles cascade deletion for Custom Resources?

Would really appreciate if you could provide some input so that I can move forward.

Copy link

@stale stale bot commented Aug 15, 2019

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 Aug 15, 2019
@stale stale bot closed this Aug 22, 2019
@rohanKanojia rohanKanojia reopened this Aug 22, 2019
@stale stale bot removed the status/stale label Aug 22, 2019
@rohanKanojia rohanKanojia added this to FKC Backlog in Project FKC Nov 5, 2019
Copy link

@rohanKanojia rohanKanojia commented Nov 13, 2019

@rimesc @Nighthawk22: Sorry for the late reply. I'm looking into this issue and found out that it's possible to set both cascading flag and propagation policies( for more fine tuned control) like this:

      NonNamespaceOperation<Dummy, DummyList, DoneableDummy, Resource<Dummy, DoneableDummy>> dummyClient = client.customResources(dummyCRD, Dummy.class, DummyList.class, DoneableDummy.class);
      if (resourceNamespaced) {
        dummyClient = ((MixedOperation<Dummy, DummyList, DoneableDummy, Resource<Dummy, DoneableDummy>>) dummyClient).inNamespace(namespace);

        // Set Cascading flag, which would set OrphanDpendents in DeleteOptions
        // Set propagation policy for deletion

However, our typeless api still hasn't got support for this. I'll add it there also then I would close this.

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Nov 13, 2019
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Nov 14, 2019
@rohanKanojia rohanKanojia moved this from FKC Backlog to Done in Project FKC Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Project FKC
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants