With finalizers in place for bundle deployments, we have one additional reconcile loop available to run cleanup tasks when a bundle deployment is deleted.
This opportunity could be used to act on Content resources, preventing their batch deletion by our cleanup controller.
Possible approaches to baking this logic into the bundle deployment reconciler:
A. When deleting a bundle deployment, check referenced Content resources and, for each Content resources, check how many bundle deployments reference it (might be expensive/cumbersome): if no other bundle deployment than the one we are deleting references it anymore, then the Content resource is safe to delete. We could increase timer for the content purge logic, or make it configurable, since garbage collection now happens as needed.
This approach would be backwards compatible
B. Add finalizers to Content resources, eg. one per bundle deployment referencing it? A given finalizer would be deleted when the bundle deployment it refers to is itself deleted. These finalizers could act as reference counts, enabling a Content resource to be deleted as soon as its finalizers have all been deleted.
This is a follow-up to #1980.
With finalizers in place for bundle deployments, we have one additional reconcile loop available to run cleanup tasks when a bundle deployment is deleted. This opportunity could be used to act on Content resources, preventing their batch deletion by our cleanup controller.
Possible approaches to baking this logic into the bundle deployment reconciler: A. When deleting a bundle deployment, check referenced Content resources and, for each Content resources, check how many bundle deployments reference it (might be expensive/cumbersome): if no other bundle deployment than the one we are deleting references it anymore, then the Content resource is safe to delete. We could increase timer for the content purge logic, or make it configurable, since garbage collection now happens as needed.
B. Add finalizers to Content resources, eg. one per bundle deployment referencing it? A given finalizer would be deleted when the bundle deployment it refers to is itself deleted. These finalizers could act as reference counts, enabling a Content resource to be deleted as soon as its finalizers have all been deleted.