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

Pass a reason to on.timer callback

GrahamDumpleton opened this issue · comments

Problem

When stacking handlers:

@kopf.on.resume("xxx.test", "workshopenvironments")
@kopf.on.create("xxx.test", "workshopenvironments")
@kopf.on.update("xxx.test", "workshopenvironments")
@kopf.on.timer("xxx.test", "workshopenvironments", interval=15.0)
def workshopenvironment_reconcile(
    reason, name, uid, body, workshopsessions_index, patch, memo, logger, **_
):
   ...

you can't use reason if on.timer is one of the handler decorators.

Proposal

Have a reason type for timers and pass it for timer callbacks, or even having reason passed as None would avoid the problem. As is, it is likely only resume and create you want to distinguish so know when resource first seen so not a problem if reason is None for a timer.

Only means to distinguish at the moment is to use param instead and supply that with different values for each decorator.

Code

No response

Additional information

No response