Repository navigation
fix(daemon): legacy systemd unit removal reloads the user manager and stops masking failures - #120027
Conversation
uninstallLegacySystemdUnits removed unit files without a daemon-reload, so the user manager kept the deleted unit definitions loaded and startable until an unrelated reload. Legacy-unit removal now reuses the shared disable-or-tolerate-missing helper, surfaces non-ENOENT unlink failures instead of swallowing them, and reloads the user manager once after any unit file was removed (matching uninstallUserSystemdGatewayUnit).
|
Codex review: needs changes before merge. Reviewed August 7, 2026, 3:38 AM ET / 07:38 UTC. ClawSweeper reviewWhat this changesThe branch centralizes systemd user-unit disable handling, surfaces legacy removal failures, and reloads the user manager after legacy unit deletion. Merge readinessThis PR remains necessary but is incorrect: it fixes the reload invariant for legacy and doctor cleanup while leaving the canonical Linux uninstall path without a post-delete manager reload. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s daemon service layer maps Linux uninstall and Doctor cleanup operations to systemd user units. Those flows disable a unit, remove its file, and must reload the user manager so its loaded definition matches disk state. flowchart LR
A[Linux uninstall or Doctor] --> B[Service registry]
B --> C[Systemd unit removal]
C --> D[Disable active unit]
D --> E[Delete unit file]
E --> F[Reload user manager]
F --> G[Accurate service state]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +29, Tests +90. Total +119 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Complete one shared post-delete reload invariant for canonical, legacy, and doctor user-unit removal, with ordered success and reload-failure regression coverage. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: successful canonical unlink has no subsequent reload, unlike both sibling removal paths; no live systemd run was executed in this read-only review. Is this the best way to solve the issue? No. The shared disable helper is appropriate, but the branch omits the canonical caller used by normal Linux uninstall, so it does not complete the stated invariant. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ea4466e5dce5. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
… stops masking failures (openclaw#120027) * fix(daemon): reload systemd user manager after removing legacy units uninstallLegacySystemdUnits removed unit files without a daemon-reload, so the user manager kept the deleted unit definitions loaded and startable until an unrelated reload. Legacy-unit removal now reuses the shared disable-or-tolerate-missing helper, surfaces non-ENOENT unlink failures instead of swallowing them, and reloads the user manager once after any unit file was removed (matching uninstallUserSystemdGatewayUnit). * chore: re-fire CI * chore: re-fire CI against fixed main baseline
What Problem This Solves
Fixes an issue where uninstalling legacy systemd gateway units left the unit startable:
uninstallLegacySystemdUnitsdeleted the unit file but never ransystemctl --user daemon-reload, so the user manager kept the deleted unit's definition loaded —systemctl startstill worked while the detector reported the unit gone. Unlink failures other than "file already gone" were also swallowed, reporting successful removal that never happened.Why This Change Was Made
The sibling path
uninstallUserSystemdGatewayUnitalready documented and handled this manager-reload invariant; legacy-unit removal now follows the same contract. The already-missing/inactive detection thatuninstallSystemdServicehad inline is extracted into a shareddisableSystemdUserUnitForRemovalhelper used by all three uninstall paths, non-ENOENT unlink errors propagate instead of printing "not found", and onedaemon-reloadruns after any unit file was actually removed.User Impact
openclaw doctor/uninstall flows on Linux leave no ghost systemd units behind, and real removal failures surface instead of being reported as success.Evidence
node scripts/run-vitest.mjs src/daemon/systemd.test.ts— passes, with new regression tests for the reload-after-removal contract, ENOENT tolerance, non-ENOENT propagation, and the shared disable helper's already-missing matching.