Repository navigation
Conversation
Add report_node_status (PUT /nodes/:id/status), report_node_component_status (PUT /nodes/:id/components/:name/status), get_node_components and find_node_components for Hub v0.21.0, plus the Node.version field.
NodeStatusReporter pushes a snapshot of all components and NodeComponentStatusReporter a single component's own status, every 60 seconds by default. A failed report is logged and retried on the next tick.
Reviewer ·
|
| Finding | File | |
|---|---|---|
Resolved in d21000c |
#1 A timed-out stop forgets a live worker, allowing a restart to leave two reporting loops running. |
flame_hub/_node_status_reporter.py |
Resolved in e1edd49 |
#2 A permanently hanging probe prevents the host process from exiting, even after the reporter is clos… |
flame_hub/_node_status_reporter.py |
Review details
| Head | e1edd49d1969fd91733040c63936fe19d802d408 |
| Last reviewed | e1edd49 |
Commands: /tada5hi review [full|<base>] · /tada5hi pause · /tada5hi resume
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
Review of 0d287fb
1 new finding, 0 resolved · full · tier 2
| Finding | Kind | Where |
|---|---|---|
#1 A timed-out stop forgets a live worker, allowing a restart to leave two reporting loops running. |
flow | flame_hub/_node_status_reporter.py:60 (inline) |
Advisory review: comments only, it never approves or requests changes.
|
|
||
| if self._thread is not None: | ||
| self._thread.join(timeout) |
There was a problem hiding this comment.
Important
#1 · flow · A timed-out stop forgets a live worker, allowing a restart to leave two reporting loops running.
Trigger: Start a reporter whose collect() or HTTP request is still in flight, call stop(timeout=0) (or any timeout shorter than the report), then call start() before the old report finishes. The old worker and the new worker share the same _stopped event, which start() clears.
Thread.join(timeout) can return while the worker is still alive, but stop() unconditionally sets _thread to None. Consequently running becomes false and a subsequent start() clears the shared stop event and launches another worker. When the original in-flight report returns, its _run() sees that same cleared event and continues reporting indefinitely alongside the new worker. This can duplicate requests and interleave stale snapshots, and the original worker is no longer tracked or joined by stop(). Keep the live thread reference after a timed-out join (and prevent restarting until it exits), or give each worker its own cancellation event. Add a lifecycle test with a blocked collector and a timed-out stop/restart.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
NodeComponentName lists the component names the Hub accepts: api, ui, podOrchestrator, storage, messenger, kong, idp, victoriaLogs.
The reporters take one probe per component instead of a collect callback. Probes run in parallel with a timeout and measured latency; a probe that raises or times out reports its component as error, and a probe still hanging from the last tick is not started again.
There was a problem hiding this comment.
Review of 7e5e168
1 new finding, 0 resolved · incremental · tier 2
| Finding | Kind | Where |
|---|---|---|
#2 A permanently hanging probe prevents the host process from exiting, even after the reporter is closed. |
flow | flame_hub/_node_status_reporter.py:62 (inline) |
Advisory review: comments only, it never approves or requests changes.
|
|
||
| self.probes = dict(probes) | ||
| self.timeout = timeout | ||
| self._executor = ThreadPoolExecutor(max_workers=len(self.probes), thread_name_prefix="node-status-probe") |
There was a problem hiding this comment.
Important
#2 · flow · A permanently hanging probe prevents the host process from exiting, even after the reporter is closed.
Trigger: A probe blocks indefinitely (for example on threading.Event().wait() or an I/O call without its own timeout); run the reporter, let probe_timeout expire, then close it and allow the host application to exit.
probe_timeout only bounds wait(); it does not stop the submitted callable. ThreadPoolExecutor workers are joined during Python interpreter shutdown, including after shutdown(wait=False, cancel_futures=True) (which cannot cancel a running future). Consequently close() can return while the stuck worker remains, but normal process exit then hangs forever. This defeats the reporter's daemon/background lifecycle precisely for the hanging-probe case this change promises to tolerate. Use a worker lifecycle that does not keep the host alive for an abandoned probe, or otherwise ensure probes terminate; add coverage for shutdown with a probe that has not been released. The current timeout test releases its probe before closing, so it misses this path.
… exit ThreadPoolExecutor workers are joined at interpreter shutdown and a running probe cannot be cancelled, so a probe that never returned kept the host process alive after close().
Summary
Hub v0.21.0 (release) lets a node report the health of its components. This PR adds the matching client methods and background reporters. It is still open whether a node reports all components together or each component reports itself, so both are supported.
API methods (
CoreClient)report_node_status(node, components, version=None):PUT /nodes/:id/status. The snapshot replaces the node's component set, andversionsetsNode.version.report_node_component_status(node, name, status, ...):PUT /nodes/:id/components/:name/status. It updates one component and leaves the others untouched.get_node_components/find_node_components:GET /node-components, withnodeincludable.NodeComponent,NodeComponentReport,NodeComponentsReportandNodeComponentProbeResult, and new typesNodeComponentStatusandNodeComponentName(api,ui,podOrchestrator,storage,messenger,kong,idp,victoriaLogs, matching feat(core-kit)!: restrict node component names to a fixed set hub#2106).Nodegainsversion.Reporters
NodeStatusReporter(core_client, node, probes={name: probe, ...}, version=...)reports a snapshot;NodeComponentStatusReporter(core_client, node, name, probe=None)reports one component.httpx.getto another service's health endpoint. The SDK contains no service-specific checks. It returnsNone(ok) or aNodeComponentProbeResult(status, version, message, counters).probe_timeout(10 s); their duration is reported aslatencyunless the probe sets one. A probe that raises or times out reports its component aserrorwith the reason, so the other components are still reported. A probe still hanging from the previous tick is not started again, so a hung service occupies at most one thread. Probes run on daemon threads, so a probe that never returns does not keep the host process from exiting.start(), then everyDEFAULT_NODE_STATUS_INTERVAL(60 s), untilstop()/close(); both work as context managers. A failed Hub request is logged and retried on the next tick, never raised into the host. The Hub marks a node offline after 5 minutes without a report.Nonefields are left out of the request body; the Hub treats a missing field andnullthe same way. The tested Hub version moves to 0.21.0.Verification
poetry run ruff check ./ruff format: passpoetry run pytest -m "not integration": 85 passed.tests/test_node_status_reporter.pyruns a realCoreClientagainst anhttpx.MockTransportfake Hub: request paths and bodies, measured and probe-supplied latency, a raising probe reportingerrorwhile the other component reportsok, timeout, no second start of a hanging probe, message truncation to the Hub's 1024 characters, failure logging, the loop surviving failures, stop/restart.ThreadPoolExecutorrunner, the subprocess test with a never-returning probe hangs at exit (timeout after 30 s).sphinx-build docs: no warnings for the new pages.tests/test_core.py(snapshot replace semantics, self-report, 403 for a non-node client, list/find with includes). The pinnedminio/minio:RELEASE.2022-12-02T19-19-22Zimage can no longer be pulled from Docker Hub or quay.io, so the testcontainers setup fails locally, and CI runs only-m "not integration".NodeComponentName; the SDK only types them.