Repository navigation
feat(heartbeat): report update_in_progress so the manager can clear updating
#98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,23 @@ def _disk_free_bytes(settings: Settings) -> int | None: | |
| return None | ||
|
|
||
|
|
||
| def _update_in_progress(settings: Settings) -> bool: | ||
| """Whether a self-update currently holds the ``/data`` update lock. | ||
|
|
||
| Reports the SAME non-blocking lock probe the controller uses to 409 | ||
| start/stop/update (HLD section 10), at the SAME path | ||
| (``$GREFFON_PATH/.update.lock``). The manager reads this to clear its | ||
| transient ``updating`` flag once an update finishes OR fails without | ||
| restarting the node (the updater dying mid-verify releases the lock but never | ||
| recreates the greffer, so no re-register fires). The probe itself fails safe | ||
| to False (cannot tell -> do not claim updating).""" | ||
| from pathlib import Path | ||
|
|
||
| from apps.utils.docker import updater | ||
|
|
||
| return updater.update_in_progress(Path(settings.greffon_path) / ".update.lock") | ||
|
|
||
|
|
||
| def _read_meminfo() -> tuple[int | None, int | None]: | ||
| """Host memory ``(used, total)`` in bytes from ``/proc/meminfo``, or | ||
| ``(None, None)``. | ||
|
|
@@ -202,6 +219,10 @@ def _one_heartbeat(app: FastAPI, seq: int) -> int: | |
| "reasons": reasons, | ||
| "disk_free_bytes": _disk_free_bytes(settings), | ||
| "instances": status_map, | ||
| # Lets the manager clear its transient "updating" flag the moment a | ||
| # self-update finishes or fails (lock released), instead of waiting out | ||
| # its grace window (covers a failed update that never restarts the node). | ||
| "update_in_progress": _update_in_progress(settings), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an operator runs Useful? React with 👍 / 👎. |
||
| } | ||
| # Host vitals (resource-monitoring epic, Feature 1). Read from /proc, | ||
| # independent of the docker status collection above, so they ride even a | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a heartbeat runs during the small window after
/remote_updatestarts the detached updater but before the updater has acquired/data/.update.lock, this call can briefly take the same exclusive non-blocking flock used byapps.utils.docker.updater.update_in_progress. The updater entrypoint also usesLOCK_EX | LOCK_NBand treats any held lock as “another update” (cli/greffer_cli/updater/__main__.py:53-58), so a regular 5s heartbeat can make a valid manager-triggered update exit as refused before it starts.Useful? React with 👍 / 👎.