nolar / kopf

A Python framework to write Kubernetes operators in just a few lines of code

Home Page:https://kopf.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document explicitly that timer/daemon override request for no finalizer.

GrahamDumpleton opened this issue · comments

Problem

Using:

@kopf.on.delete("example.com", "v1alpha1", "example", optional=True)
def example_delete(**_):
    pass

with expectation that a finalizer will not be added for kopf operator to resource.

At the same time using @kopf.timer on same resource type.

Use of @kopf.timer overrides optional=True in @kopf.on.delete and makes finalizer mandatory.

See

kopf/kopf/on.py

Line 764 in 91e8fd6

initial_delay=initial_delay, requires_finalizer=True,

Not even speculating on why that is required for a timer, but I can't seem to find a warning on docs for timer that using it will cause optional=True in @kopf.on.delete to be ignored.

Proposal

Add warning in docs if analysis is correct and this is a requirement for using @kopf.timer. IOW, warn that optional argument to @kopf.on.delete will be overridden.

Code

No response

Additional information

The @kopf.daemon also overrides requirement for finalizer. The docs for it have section https://kopf.readthedocs.io/en/stable/daemons/#deletion-prevention and finalizers are mentioned, although still isn't explicit in saying that optional=True will be ignored in @kopf.on.delete as a result.

Section https://kopf.readthedocs.io/en/stable/handlers/#state-changing-handlers in docs where mentions optional=True should also perhaps note that this will be ignored in case of @kopf.timer and @kopf.daemon being used.