operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

Add ability to prune unreferenced resources in ansible operators

Open fbladilo opened this issue 3 years ago • 3 comments

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

  1. Use ansible operator to deploy an application
  2. Have an application spawn jobs/pods without reference
  3. 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 avatar Jul 25 '22 15:07 fbladilo

@fbladilo Have you tried using finalizers? If so, can you elaborate on why they are insufficient?

asmacdo avatar Aug 01 '22 16:08 asmacdo

@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.

fbladilo avatar Aug 08 '22 21:08 fbladilo

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.

asmacdo avatar Aug 15 '22 16:08 asmacdo

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

openshift-bot avatar Nov 14 '22 01:11 openshift-bot

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

openshift-bot avatar Dec 14 '22 08:12 openshift-bot

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 avatar Jan 14 '23 00:01 openshift-bot

@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.

openshift-ci[bot] avatar Jan 14 '23 00:01 openshift-ci[bot]