Add ability to prune unreferenced resources in ansible operators
Feature Request
Add the capability to prune non-referenced resources to ansible operator , the need is essentially the same as addressed by :
Resource Pruning for Go operators.
Describe the problem you need a feature to resolve.
Allow ansible operator users to remove un-referenced resources
Reproduce
- Use ansible operator to deploy an application
- Have an application spawn jobs/pods without reference
- Delete watched CR (and watch un-pruned resources leftover)
Describe the solution you'd like.
Perhaps a collection that is included by Operator SDK and allows cleaning up by label or similar within operator's namespace.
@fbladilo Have you tried using finalizers? If so, can you elaborate on why they are insufficient?
@asmacdo The resources we are trying to delete are actually k8s resources in the watched operator namespace, my understanding of finalizers is to provide a way to perform more complex tasks outside k8s (cleaning up 3rd party APIs , etc). That is the reason I pointed to example of resource pruning helpers in Go documentation in the issue, because our use case falls along those lines.
It is plausible that we could use a finalizer to perform k8s deletion of resources in our own namespace once the CR gets marked for deletion but I don't think that is the best use case for them (or perhaps flat out not recommended) as it could potentially block the CR deletion if there are issues with the finalizer itself.
It is appropriate to use finalizers for k8s resources as well, this is what we recommend for cleaning up cluster scoped resources that belong to a CR (for example).
Closing for now, please feel free to reopen.
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle rotten /remove-lifecycle stale
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.
/close
@openshift-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting
/reopen. Mark the issue as fresh by commenting/remove-lifecycle rotten. Exclude this issue from closing again by commenting/lifecycle frozen./close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.