kopf
kopf copied to clipboard
any way to to retrigger the failed on.create / on.update / on.delete event
Context:
- Assume that kopf failed to handle the on.create/on.update event (some business logic error). In this case desired state is saved in etcd database, right?.
- Later if we try to do the same create/update via "kubectl apply", i says unchanged, because desired state already there in etcd database.
- In this situation how can i inform k8s to please try again to move to desired state (assume that all kopf retries are already failed in the first attempt)
- I know that, we can delete the failed resource from k8s and recreate it, that way it again come to on.create handler, but that is not a good approach in our use case.
- Please let us know if you have any thought
Does kopf.daemon handler help ? for example, retry infinitely ? :) We can use daemon handler as a Control Loop ?
If kubectl does not change the resource, Kopf will never know that anything was attempted at all.
One hack to think about is to ensure the changes on every kubectl apply. For this, put a label/annotation/field X with a value of 1 in yaml. In the operator, always overwrite it to 2. Every time kubectl apply is called, it will modify it back to 1 and trigger the processing cycle.
This hack does not work if you cannot make a convention to have that X in yamls.
If you would wait indefinitely long (I’d say, several weeks to a couple of months — depends on my free time), there would be mutating admission handlers (google: dynamic admission control). They would be able to inject random values to X themselves. But only if kubectl initiates talking to the K8s API at all (I’m not sure about this).
mutating admission webhook is a good option for this use case, thanks for the suggestion. right now i am using validating admission webhook for validate the CR spec before applying it to etcd.