Skip to content

feat: node status reporting with probe-based reporters - #154

Open
tada5hi wants to merge 7 commits into
mainfrom
feat/node-status-reporting
Open

tada5hi wants to merge 7 commits into
mainfrom
feat/node-status-reporting

Conversation

@tada5hi

@tada5hi tada5hi commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

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, and version sets Node.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, with node includable.
  • New models NodeComponent, NodeComponentReport, NodeComponentsReport and NodeComponentProbeResult, and new types NodeComponentStatus and NodeComponentName (api, ui, podOrchestrator, storage, messenger, kong, idp, victoriaLogs, matching feat(core-kit)!: restrict node component names to a fixed set hub#2106). Node gains version.

Reporters

  • NodeStatusReporter(core_client, node, probes={name: probe, ...}, version=...) reports a snapshot; NodeComponentStatusReporter(core_client, node, name, probe=None) reports one component.
  • A probe is a function written by the service, e.g. an httpx.get to another service's health endpoint. The SDK contains no service-specific checks. It returns None (ok) or a NodeComponentProbeResult (status, version, message, counters).
  • Probes run in parallel and are bounded by probe_timeout (10 s); their duration is reported as latency unless the probe sets one. A probe that raises or times out reports its component as error with 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.
  • The reporters report once on start(), then every DEFAULT_NODE_STATUS_INTERVAL (60 s), until stop()/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.

None fields are left out of the request body; the Hub treats a missing field and null the same way. The tested Hub version moves to 0.21.0.

Verification

  • poetry run ruff check . / ruff format: pass
  • poetry run pytest -m "not integration": 85 passed. tests/test_node_status_reporter.py runs a real CoreClient against an httpx.MockTransport fake Hub: request paths and bodies, measured and probe-supplied latency, a raising probe reporting error while the other component reports ok, timeout, no second start of a hanging probe, message truncation to the Hub's 1024 characters, failure logging, the loop surviving failures, stop/restart.
  • Negative controls: removing the hang guard fails the "not started twice" test; re-raising a probe's exception fails the "raising probe" test; with the earlier ThreadPoolExecutor runner, the subprocess test with a never-returning probe hangs at exit (timeout after 30 s).
  • sphinx-build docs: no warnings for the new pages.
  • Not verified: the integration tests in tests/test_core.py (snapshot replace semantics, self-report, 403 for a non-node client, list/find with includes). The pinned minio/minio:RELEASE.2022-12-02T19-19-22Z image can no longer be pulled from Docker Hub or quay.io, so the testcontainers setup fails locally, and CI runs only -m "not integration".
  • Until feat(core-kit)!: restrict node component names to a fixed set hub#2106 is released, the Hub still accepts names outside NodeComponentName; the SDK only types them.

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.
Copilot AI balanced review requested due to automatic review settings December 4, 2026 08:41
@tada5hi

tada5hi Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Reviewer · e1edd49 reviewed

Tip

No open findings. 2 resolved. Read the review

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tada5hi tada5hi Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +58 to +60

if self._thread is not None:
self._thread.join(timeout)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Resolved in d21000c.

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 184608f9-1cd0-4def-abcb-bf4224ec8951

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@tada5hi tada5hi Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of d21000c

Tip

0 new findings, 1 resolved · incremental · tier 2

Resolved: #1

Advisory review: comments only, it never approves or requests changes.

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.
@tada5hi tada5hi changed the title feat: node status reporting feat: node status reporting with probe-based reporters Dec 4, 2026

@tada5hi tada5hi Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread flame_hub/_node_status_reporter.py Outdated

self.probes = dict(probes)
self.timeout = timeout
self._executor = ThreadPoolExecutor(max_workers=len(self.probes), thread_name_prefix="node-status-probe")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Resolved in e1edd49.

… 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().

@tada5hi tada5hi Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of e1edd49

Tip

0 new findings, 1 resolved · incremental · tier 2

Resolved: #2

Advisory review: comments only, it never approves or requests changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants