crate.operator.utils.kopf module

class crate.operator.utils.kopf.Notification

Bases: TypedDict

event: WebhookEvent
payload: WebhookSubPayload
status: WebhookStatus
class crate.operator.utils.kopf.StateBasedSubHandler(namespace, name, ref, context, depends_on=None, run_on_dep_failures=False, operation=None)

Bases: ABC

A handler capable of waiting for other handlers to finish.

This can be expressed as a set of dependencies passed to the depends_on parameter of the constructor.

Basically, we wrap an actual handler here. Before executing the actual one, we check if the dependencies have completed yet - we do this by checking the statuses of those dependent handlers, as stored in the status field of the CrateDB resource.

Parameters:
abstractmethod async handle(**kwargs)
Parameters:

kwargs (Any)

schedule_notification(event, payload, status)
Parameters:
async send_notification_now(logger, event, payload, status)
Parameters:
async send_registered_notifications(logger)
Parameters:

logger (Logger)

async crate.operator.utils.kopf.send_webhook_notification(namespace, name, logger, event, payload, status)
Parameters:
crate.operator.utils.kopf.subhandler_partial(awaitable, *args, **kwargs)

A utility function to create a partial coroutine suitable for kopf.register.

When scheduling asynchronous sub-handlers in Kopf, one needs to be careful to not create coroutines when they’re not used in an execution cycle.

>>> async def some_coro(arg1, kwarg1=None):
...     pass
>>> kopf.register(
...     fn=subhandler_partial(
...         some_coro,
...         'abc',
...         kwarg1='foo',
...     ),
...     id="some-id",
... )
Parameters:

awaitable (Callable)