cisco-open / operator-tools

Speed up the implementation and composition of Kubernetes Operators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow logic to compare current and desired objects before deletion

pepov opened this issue · comments

Is your feature request related to a problem? Please describe.
The following issue describes the problem in a real world situation:
banzaicloud/thanos-operator#134

Describe the solution you'd like to see
I would like to see a new Interface introduced and checked by the resource reconciler by passing not just the desired but the current object as well. So similar to:

type DesiredStateShouldDelete interface {
	ShouldDelete(desired runtime.Object) (bool, error)
}

but extended with current:

type DesiredStateShouldDelete interface {
	ShouldDelete(current, desired runtime.Object) (bool, error)
}

In that case we should be able to add a common function to check if an existing resource has a given label, before deleting it.