kopf
kopf copied to clipboard
Make backoff, timeout and retries configurable globally
Problem
We have quite a few handlers in our Operator and would now like to configure the maximum number of retries, timeouts etc. for those handlers. At the moment it looks like we would need to do that on each individual handler. Since we plan to use the same values everywhere this would be quite repetitive.
Proposal
Make the timeout
, retries
and backoff
options of the handler configurable via the OperatorSettings
so we can set them during Operator startup. The parameters on the handlers should still have priority, so that you can overwrite the configured defaults if necessary.
Code
import kopf
@kopf.on.startup()
def configure(settings: kopf.OperatorSettings, **_: Any) -> None:
settings.handling.retries = 3
settings.handling.backoff = 30
settings.handling.timeout = 60 * 60
# Overwrites the default
@kopf.on.create('kopfexamples', retries=5)
def create_fn(spec, **_):
...
# Uses the default value
@kopf.on.delete('kopfexamples')
def create_fn(spec, **_):
...
Additional information
No response