async def handle_resource_watching_cause( lifecycle: lifecycles.LifeCycleFn, registry: registries.OperatorRegistry, memory: containers.ResourceMemory, cause: causation.ResourceWatchingCause, ) -> None: """ Handle a received event, log but ignore all errors. This is a lightweight version of the cause handling, but for the raw events, without any progress persistence. Multi-step calls are also not supported. If the handler fails, it fails and is never retried. Note: K8s-event posting is skipped for `kopf.on.event` handlers, as they should be silent. Still, the messages are logged normally. """ handlers = registry.get_resource_watching_handlers(cause=cause) outcomes = await _execute_handlers( lifecycle=lifecycle, handlers=handlers, cause=cause, state=states.State.from_scratch(handlers=handlers), default_errors=registries.ErrorsMode.IGNORED, ) # Store the results, but not the handlers' progress. states.deliver_results(outcomes=outcomes, patch=cause.patch)
async def handle_resource_watching_cause( lifecycle: lifecycles.LifeCycleFn, registry: registries.OperatorRegistry, cause: causation.ResourceWatchingCause, ) -> None: """ Handle a received event, log but ignore all errors. This is a lightweight version of the cause handling, but for the raw events, without any progress persistence. Multi-step calls are also not supported. If the handler fails, it fails and is never retried. Note: K8s-event posting is skipped for `kopf.on.event` handlers, as they should be silent. Still, the messages are logged normally. """ logger = cause.logger handlers = registry.get_resource_watching_handlers(cause=cause) for handler in handlers: # The exceptions are handled locally and are not re-raised, to keep the operator running. try: logger.debug(f"Invoking handler {handler.id!r}.") result = await _call_handler( handler, cause=cause, lifecycle=lifecycle, ) except Exception: logger.exception( f"Handler {handler.id!r} failed with an exception. Will ignore.", local=True) else: logger.info(f"Handler {handler.id!r} succeeded.", local=True) state.store_result(patch=cause.patch, handler=handler, result=result)