Repository navigation
feat(heartbeat): report update_in_progress so the manager can clear updating - #98
Conversation
…updating` The greffer now reports update_in_progress in every heartbeat: the same non-blocking flock probe of $GREFFON_PATH/.update.lock the controller uses to 409 start/stop/update (HLD section 10). The manager uses a settled false to clear its transient `updating` UI flag, which otherwise stuck for the full 600s grace after a manager-triggered update. This is the signal that covers an update which FAILS WITHOUT restarting the node (the updater dies during verify/pull before any recreate): the node keeps beating, so no re-register fires, and the manager would otherwise show "updating" until the grace lapsed. The probe fails safe to False. Bump 0.3.9 -> 0.3.10. Pairs with the manager fix; the manager handles the field's absence (older greffers) gracefully.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c18cf8e69a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| from apps.utils.docker import updater | ||
|
|
||
| return updater.update_in_progress(Path(settings.greffon_path) / ".update.lock") |
There was a problem hiding this comment.
Do not let heartbeats contend with the update lock
When a heartbeat runs during the small window after /remote_update starts the detached updater but before the updater has acquired /data/.update.lock, this call can briefly take the same exclusive non-blocking flock used by apps.utils.docker.updater.update_in_progress. The updater entrypoint also uses LOCK_EX | LOCK_NB and 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 👍 / 👎.
…se an update
Codex review (greffer#98): the new heartbeat update_in_progress probe (and the
controller's start/stop/update guard) take LOCK_EX|LOCK_NB on /data/.update.lock
acquire-then-immediately-release. The detached updater's one-shot acquire could
land inside that microsecond hold and exit EXIT_REFUSED ("another update in
progress") before the update even starts.
acquire_lock now retries briefly (~1s) before giving up: a transient probe hold
is absorbed, while a genuine concurrent update (holds the lock for its whole run)
still refuses after the bounded retry. Also hardens the pre-existing
controller-probe vs updater-acquire contention.
|
Good catch — fixed in 2dfc315. Confirmed the updater's |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2dfc315b7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # 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.
Retry the host CLI lock path as well
When an operator runs greffer update while the daemon is otherwise idle, this new per-heartbeat probe briefly takes the same $GREFFON_PATH/.update.lock exclusive flock; the host CLI still does a single non-blocking flock in cli/greffer_cli/update.py:406-409 and returns EXIT_PREFLIGHT_REFUSED at cli/greffer_cli/update.py:517-521, so a valid manual update can be rejected just because it landed during a heartbeat. The in-container updater was given a bounded retry for this same probe race, but the host update path needs the same treatment or the heartbeat should avoid taking an exclusive lock.
Useful? React with 👍 / 👎.
Codex review (greffer#98 round 2): the bounded-retry fix for the in-container updater's acquire_lock left the HOST `greffer update` path (update.py _acquire_update_lock) still doing a one-shot LOCK_EX|LOCK_NB. The greffer's new per-heartbeat update_in_progress probe holds the same /data/.update.lock for microseconds, so a manual `greffer update` landing in that window would be spuriously refused (EXIT_PREFLIGHT_REFUSED). Apply the same ~1s bounded retry to the host lock: a transient probe hold is absorbed; a genuine concurrent run (host or in-container updater) still refuses after the retry.
|
Good catch — fixed in 719164c. You're right that the bounded retry only covered the in-container updater; the host (Note: the host-CLI fix ships in a new |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Resolve the heartbeat-payload conflict by keeping BOTH features: cert_serial (R-DR10 DR reconciliation, this branch) and update_in_progress (self-update clear, from main #98). Both keys ride the same beat; the two new tests become two separate self-contained tests. 35 heartbeat tests pass.
Why
The manager's
updatingUI flag stayed stuck for the full 600s grace after a manager-triggered remote update, because the manager had no signal for "the update is no longer in flight" — see the pairedgreffon/managerPR. The case that needs an explicit signal is an update that fails without restarting the node (the updater dies during verify/pull before any recreate): the greffer keeps heartbeating, so no re-register fires.Change
Report
update_in_progressin every heartbeat: the same non-blocking flock probe of$GREFFON_PATH/.update.lockthe controller already uses to 409 start/stop/update (HLD §10), at the same path. The manager treats a settledfalseas "done/failed" and clears the flag. The probe fails safe toFalse(can't tell → don't claim updating).Bump 0.3.9 → 0.3.10.
Pairing / rollout
Pairs with
greffon/manager(clearslast_update_started_aton re-register + on this heartbeat signal). The manager change is backward-compatible and deploys first; a greffer that omits this field falls back to the manager's re-register clear + grace. This field adds the no-restart-failure clear once a greffer runs 0.3.10+.Tests
test_one_heartbeat_reports_update_in_progress(reports the probe + probes the controller's lock path) and an assertion in the existing payload test. Heartbeat + register suites green.🤖 Generated with Claude Code