Health reporting¶
A node tells the platform whether it is operationally healthy: a boolean plus a short message that the editor shows next to the node. The SDK does the streaming for you. After reading this page you can decide what "healthy" means for your node, report it from one hook, push an update the moment a fault happens, and know what the Mock Runner shows you of it.
Status is not health¶
The platform tracks two different things per node.
| Status | Health | |
|---|---|---|
| Question answered | Where is the node in its lifecycle? | Can the node do its job right now? |
| Values | IDLE, CONFIGURED, RUNNING, PAUSED, STOPPED, ERROR |
isHealthy: true/false plus a message |
| Who decides | The SDK state machine, driven by configure, execute, stop | Your node, through on_health_check() |
| Your work | None | None by default; one hook override when you have something to report |
The two are independent by default. A node can be RUNNING and unhealthy (the robot it drives is in collision), or CONFIGURED and healthy (idle, device connected). Health does not change the state machine unless the service opts into unhealthy escalation. If a fault should abort the current run immediately, raise from on_execute() as usual (a NodeDependencyError for a device fault, see Errors) and report the health on top.
Node health is not container health¶
Since SDK 2.49.0
What this page describes is per node and goes to the editor. The container also answers
liveness and readiness probes for Docker and Kubernetes (/health/live, /health/ready and
grpc.health.v1.Health, see Probes). Those report on the
process only. An unhealthy node never fails them: restarting the container does not reconnect
your camera, and taking it out of traffic would hide the fault from the editor.
What happens without any code¶
If you override nothing, on_health_check() returns True and the message is "Healthy". The SDK then does the following on its own:
- Right after
on_configure()succeeds it runs the check once and pushes the snapshot. - It starts a background monitor that re-runs the check every
health_stream_check_interval_sseconds (default 10 s). - A snapshot is sent only when the pair
(isHealthy, message)differs from the last one sent, so a node that stays healthy produces one message, not one every 10 seconds. - On stop the monitor is stopped and the health stream is closed. The next configure starts over with a fresh snapshot.
For most nodes that transform data and hold no external resource this is all the health reporting you need.
Report your own health¶
Override on_health_check() -> bool. Return True for healthy and False for unhealthy, and set self._health_check_message to the text the editor should show. The check runs once at the end of configure and then on the SDK's monitor thread, so keep it fast, read state that already exists and do not talk to the device inside the hook.
The smart-home tutorial node reports whether its device handle exists:
def on_health_check(self) -> bool:
"""Run by the SDK right after configure and on each periodic health poll.
The message set here is what the editor shows next to the health state.
"""
if self._device is None:
self._health_check_message = "Light device handle is missing (node not configured)"
return False
self._health_check_message = f"Connected to light at {self._light_ip}"
return True
Rules the SDK applies around your hook:
| Behaviour | Detail |
|---|---|
| Message reset | _health_check_message is cleared to None before every call. Set it on every path you care about, or the default text is used. |
| Default text | "Healthy" when you return True, "Unhealthy" when you return False and set no message. |
| Exceptions | Never escape. An exception in your hook is logged at ERROR and reported as unhealthy with the message Health check failed: <error>. That sample can start escalation when the service has opted in. |
| Log line | Healthy check result: <bool>, message: <text> at INFO, written when the (bool, message) pair differs from the last line written. A repeated identical result is not logged again, so the periodic check stays quiet while nothing changes, and configure() starts a fresh comparison so the first check after it always logs. |
| Wire type | None. You return a bool; the SDK builds the {nodeId, isHealthy, resultMessage} record itself. |
The full node, including where the device handle is opened and released, is in the smart home tutorial.
Push a change immediately¶
Between two monitor ticks up to 10 seconds pass. When your code learns about a fault or a recovery right away, push it yourself:
self.send_health_update(False, "Light command failed: connection refused")
send_health_update(is_healthy, message) behaves like this:
| Behaviour | Detail |
|---|---|
| Immediate | The snapshot goes to the stream now, without waiting for the monitor. |
| Deduplicated | Identical (is_healthy, message) pairs are dropped, so calling it on every execute is cheap. |
| No-op before configure | Until the SDK has attached the node to a graph (stream and node id present) the call returns silently. Safe to call from anywhere, including tests. |
| Overwritten by the next check | The monitor keeps running. If on_health_check() still returns True after you pushed a fault, the next tick reports healthy again. Make the hook read the same state your fault handler sets. |
The tutorial node does exactly that in on_execute(): it pushes False with the failure text when the device call raises, then raises NodeExecutionError so the run is marked as failed too. Because on_health_check() reads the same _device attribute, the periodic check agrees with the pushed snapshot.
Pick one source of truth
Store the fault in an attribute (self._last_error, a connection flag, a timestamp of the last good reading) and derive both the pushed update and on_health_check() from it. Two independent opinions about health are the usual cause of a status that flips every 10 seconds.
Turning the periodic check off¶
The interval lives in the node service configuration, not in the node. Set it to 0 (or a negative number) to disable the monitor; the snapshot right after configure is still sent, and send_health_update() still works.
| Key | Default | Meaning |
|---|---|---|
health_stream_check_interval_s |
10.0 |
Seconds between automatic on_health_check() runs. 0 or negative disables the periodic monitor. |
escalate_unhealthy_to_error |
false |
Move a running node to ERROR after a continuous unhealthy period. Off by default. |
unhealthy_escalate_after_s |
7.0 |
Seconds the node must stay unhealthy before that escalation. |
status_stream_heartbeat_interval_s |
1.0 |
Status stream only. Unrelated to health. |
Every service configuration key is listed in the service configuration reference.
Escalate unhealthy to ERROR¶
The whole section below needs SDK 2.41.0 or newer. On an older SDK the two keys are ignored and health never changes the node state.
Health stays telemetry-only unless the node service sets escalate_unhealthy_to_error: true. Then a node that is RUNNING and stays unhealthy for unhealthy_escalate_after_s (default 7 s) moves to ERROR and fires the Error trigger with err_type=HealthFaultEscalation.
How it behaves:
| Rule | Detail |
|---|---|
| Opt-in | Default false. Existing nodes keep health-red-only behaviour. |
| Debounce | The first unhealthy sample (including a hook exception) starts a one-shot waiter. A healthy sample cancels it and resets the latch. |
| Once per fault | The same continuous unhealthy period fires Error at most once. A later healthy sample clears the latch so a new fault can escalate again. |
RUNNING only |
Configured or already-ERROR nodes are not escalated. |
| Needs polling | Keep health_stream_check_interval_s greater than 0, or nothing samples. |
| Late execute | If the waiter flips the node to ERROR while on_execute() is still running, a later success does not configure() or fire Start/Stop. |
Example service config:
health_stream_check_interval_s: 1
escalate_unhealthy_to_error: true
unhealthy_escalate_after_s: 7
Since SDK 2.48.0
C++ nodes have the same escalation. Set escalate_unhealthy_to_error and unhealthy_escalate_after_s in NodeServiceConfig in main(); see Health escalation.
Escalation does not clear the device. Resetting a robot collision or reconnecting hardware stays a recovery-node or operator concern.
Testing health in unit tests¶
get_health_check() is the public method the SDK itself calls around your hook. It returns the (is_healthy, message) tuple and never raises, so tests can assert on it directly. send_health_update() is silent until you give the node a queue and an id, which the SDK does in production:
import queue
node = SmartLightNode()
node.data_flow = FakeDataFlow()
node.on_configure({}, None)
assert node.get_health_check() == (True, "Connected to light at 192.168.1.50")
node.health_queue = queue.Queue() # the SDK attaches these when a graph is configured
node.node_id = "smart-light-1"
node.send_health_update(False, "Light offline")
assert node.health_queue.get_nowait()["isHealthy"] is False
FakeDataFlow and the test layout are described in Testing; the complete test module is examples/tutorials/smart_home/test_smart_home_node.py.
In the Mock Runner¶
The Mock Runner calls the real configure path, so on_health_check() runs exactly once when you press Configure and its Healthy check result: ... line appears in the Node Logs tab. That is all you see:
- there is no health stream and no health indicator in the mock UI,
- the periodic monitor does not run,
send_health_update()is a no-op there, because no stream is attached.
Use the mock to check that your hook returns the right value and message after configure. Everything time-based, and the editor display, needs a real engine.
Checklist¶
| Goal | What to do |
|---|---|
| Ship with defaults | Nothing. The node reports Healthy after configure. |
| Report a device or connection state | Override on_health_check(), set self._health_check_message, return a bool. |
| Show a fault the moment it happens | Call self.send_health_update(False, "...") in the fault handler; make on_health_check() read the same state. |
| Report recovery | Push send_health_update(True, "...") or let the next periodic check pick it up. |
| Stop the 10 s polling | Set health_stream_check_interval_s: 0 in the service configuration. |
Turn a sustained unhealthy period into ERROR |
Set escalate_unhealthy_to_error: true and keep periodic checks enabled. See Escalate unhealthy to ERROR. |
| Test it | Assert on node.get_health_check(); attach a queue.Queue as health_queue to inspect pushed snapshots. |