Repository navigation
Implement the Daemon section on the Control page - #259
Open
yakutovicha wants to merge 20 commits into
Open
yakutovicha wants to merge 20 commits into
yakutovicha wants to merge 20 commits into
Conversation
Member
yakutovicha
force-pushed
the
feature/daemon-tab
branch
from
October 23, 2026 10:41
cf5c595 to
ae56825
Compare
Replace the DaemonControlWidget placeholder with daemon management: a status line with the worker count (warning when workers exceed the CPUs), a per-worker stats table, start/stop/restart, add/remove worker, and a collapsible tail of the daemon log. - Actions run on a background thread with feedback. All buttons are disabled meanwhile and re-enabled before the status is re-probed, so a failing probe cannot leave the page locked; refresh() is a no-op during an action, so revisiting the tab cannot re-enable them early. - get_worker_info() is only called once is_daemon_running holds (it blocks for the client timeout otherwise). A daemon that stopped in between shows as not running, an unreachable one as an error. - Restart falls back to start when the daemon is stopped. Removing the last worker is refused after re-checking the live count. - The log tail (last 50 lines, reading at most 64 KiB) loads when the accordion opens and follows status updates while open. Add unit tests for the probe, age humanizer, log tail reader, worker table rendering (including circus' message for a stopped worker), the button-state sync and the actions against a fake daemon client.
circus refuses a command that clashes with one still in progress, for
example removing a worker while a previously removed one is still
shutting down, and reports it as {"status": "error", "reason": ...}
in its reply instead of raising. The Daemon section ignored the reply
and announced success, e.g. "A worker has been removed.", although
nothing happened.
Check the reply in _run_action and show circus's reason as the
failure; the restart and remove-worker helpers now return it.
Add a test with a fake daemon that refuses to remove a worker.
The Start button, and the start fallback of Restart, called start_daemon() with its default of one worker. `verdi daemon start`, which the container uses at startup, starts daemon.default_workers instead, so a user who configured more workers got only one after stopping and starting the daemon from the Control page. Pass the profile's daemon.default_workers, as verdi does. The fake daemon now requires the number of workers; the start and restart-fallback tests check that the configured number is used.
After a daemon action, _run_action re-enables the buttons before it re-probes the status, and reports a probe failure after the action's own message. So a failing probe can neither leave the page with all buttons disabled nor hide the action's result. Nothing tested this. Add a test whose status probe raises after a successful stop.
Flatten _probe_daemon_workers into a single try with two excepts; the behaviour is unchanged, since is_daemon_running only reads the PID file and cannot raise DaemonNotRunningException. List the daemon's action buttons once and build the button row from that list, instead of repeating the five buttons. No behaviour change; the existing probe and action tests cover both.
yakutovicha
force-pushed
the
feature/daemon-tab
branch
from
November 3, 2026 16:21
ae56825 to
4b972cf
Compare
It was hidden in #275 while the section was a placeholder; it is now implemented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
circus replied before the worker had started or stopped, so the status shown after removing a worker still listed it. Pass wait=True with a timeout above circus' 30 s graceful shutdown, and show a timeout as a warning, since circus still completes the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
Okay, this has been fixed in df0de83. The problem was that the UI didn't wait for the process to finish, so it was still showing 4 workers, while 1 was shutting down. |
circus stops the oldest worker, which surprised the reviewer. While it shuts down, mark its row as stopping and name its PID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
This is how circus' code works: it stops the oldest worker; naturally, the smallest ID gets removed. In this commit, it is made explicit: d44db6c |
Member
Author
I removed the button. The log is anyway getting reloaded after one presses "Refresh" |
Member
Author
Probably not; it is already cut to 50 lines. Hard to imagine what the use case would be. 8000 |
An action started during a refresh, e.g. right after opening the tab, ran alongside it: the refresh then cleared the action's message and re-enabled the buttons. Show a warning instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A timeout means circus did not answer within 40 s, usually because a worker is still stopping, but possibly because circus is stuck. Say so instead of asserting that the worker is still starting or stopping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the log tail size and the worker change timeout together at the top of the daemon code, instead of spread over the module and the class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker table and the choice of the worker shown as stopping each sorted the workers by age their own way. Share one helper, so the top row and the stopping worker are the same by construction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover the not-running warnings of stop/add/remove, a plain restart, timeouts of start/stop/restart (errors, unlike add/remove), removing a worker when none reports an age, and an unreadable daemon log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The six tests differed only in the daemon's state and the expected result. Every row now compares the whole result, and a stopped daemon must not be asked for its workers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show side by side that a timeout fails start, stop and restart, but only warns for adding or removing a worker, and check that the buttons come back in every case. The restart failure test went through the same path as the restart timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stopped, one-worker and two-worker states of the Add/Remove worker buttons were spread over three tests. The status and table checks dropped from them are covered by the stop/start and add/remove tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Start on a running daemon and stop/add/remove on a stopped one only show a warning. Test them together, also checking the warning color. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check formatting, oldest-first order and the hidden circus ids on one table whose workers are not listed in order, as circus may report them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #254
Replaces the
DaemonControlWidgetplaceholder with:daemon.default_workers, asverdi daemon startdoes.Actions run on a background thread with feedback. All buttons are disabled meanwhile and re-enabled before the status is re-probed;
refresh()is a no-op during an action, so revisiting the tab can't re-enable them early.Notes for review:
get_worker_info()is only called onceis_daemon_runningholds, since it blocks for the client timeout otherwise. OnlyDaemonNotRunningExceptioncounts as "not running"; other daemon errors (e.g. a stale PID file) show as an error with AiiDA's message, which says how to fix it.{"status": "error", "reason": ...}, instead of raising. Such refusals are shown as failures rather than reported as success.DaemonClient.restart_daemon()(restarts the workers). Note thatverdi daemon restartin AiiDA 2.9 does a full stop + start instead.Tests
Unit tests for the probe, age humanizer, log tail reader, worker table rendering and button-state sync, plus, against a fake daemon client, the start/stop/restart/add/remove flows, the configured worker count, refused commands and a failing re-probe after an action; and a refresh with the test profile's real client.
🤖 Generated with Claude Code