Repository navigation
fix(systemd): clear start-limit latch before gateway start - #116178
Conversation
924d6c7 to
0fea36c
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 12:26 AM ET / 04:26 UTC. ClawSweeper reviewWhat this changesUpdates gateway systemd start handling so a managed user or system unit has its failed/start-limit latch cleared before Merge readinessKeep this PR open for normal maintainer review. It addresses the linked systemd recovery bug with focused service-action changes, supplied real Linux/systemd proof, and targeted coverage; no concrete patch defect is established, but the availability-sensitive start-path behavior should be accepted on the current head rather than auto-closed or auto-repaired. Priority: P1 Review scores
Verification
How this fits togetherThe gateway CLI delegates start, restart, and stop requests to the shared systemd service-control helper. That helper checks service ownership, invokes flowchart LR
A[Operator runs gateway start] --> B[Gateway service control]
B --> C[Check unit scope and ownership]
C --> D[Clear failed start-limit latch]
D --> E[Run systemctl start]
E --> F[Gateway becomes active or reports failure]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -2, Tests +56. Total +54 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow shared-helper fix if the current merge head preserves reset-before-start ordering, ownership guards, reset-failure tolerance, and stop isolation across both system and user scopes. Do we have a high-confidence way to reproduce the issue? Yes. The PR supplies a concrete Linux systemd 255 path that drives a managed gateway into start-limit failure, observes raw start rejection, then demonstrates successful OpenClaw CLI recovery after the process becomes healthy. Is this the best way to solve the issue? Yes. Extending the existing shared systemd action owner preserves the established restart recovery contract for start without adding configuration, a parallel workflow, or a new command surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5496cff9653b. LabelsLabel justifications:
EvidenceWhat 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 (7 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
systemd latches a unit into failed/start-limit-hit after a crash loop, then refuses systemctl start until reset-failed clears the latch. The reset-failed step only ran for the restart action, so the natural recovery command `openclaw gateway start` failed on a crash-looped gateway while `openclaw gateway restart` recovered it. Run reset-failed before both start and restart (stop is unchanged), mirroring launchd's startLaunchAgent which calls launchctl enable before kickstart. reset-failed is idempotent and a no-op on a healthy unit.
Mirrors the existing system-scope restart test: when startSystemdService targets a system unit as root, it must emit reset-failed before start so a crash-looped gateway recovers via `openclaw gateway start` too.
reset-failed is idempotent on a non-failed unit (systemd returns success without changing unit state), so prepending it to start cannot regress a healthy gateway. Covers the merge-risk concern that every start now depends on an extra reset-failed call.
49c4237 to
a75ac9e
Compare
|
Maintainer review complete. ClawSweeper’s current-head validation move is satisfied by exact-head CI on I am not rebasing again solely because |
|
Merged via squash.
|
…116178) * fix(systemd): clear start-limit latch before gateway start systemd latches a unit into failed/start-limit-hit after a crash loop, then refuses systemctl start until reset-failed clears the latch. The reset-failed step only ran for the restart action, so the natural recovery command `openclaw gateway start` failed on a crash-looped gateway while `openclaw gateway restart` recovered it. Run reset-failed before both start and restart (stop is unchanged), mirroring launchd's startLaunchAgent which calls launchctl enable before kickstart. reset-failed is idempotent and a no-op on a healthy unit. * test(systemd): cover start-limit latch clearing on system-scope start Mirrors the existing system-scope restart test: when startSystemdService targets a system unit as root, it must emit reset-failed before start so a crash-looped gateway recovers via `openclaw gateway start` too. * test(systemd): assert healthy start tolerates reset-failed no-op reset-failed is idempotent on a non-failed unit (systemd returns success without changing unit state), so prepending it to start cannot regress a healthy gateway. Covers the merge-risk concern that every start now depends on an extra reset-failed call. * test(systemd): cover reset failure and stop controls --------- Co-authored-by: Vincent Koc <[email protected]>
* origin/main: (24 commits) fix(e2e): apply default service identity per flow (openclaw#116265) chore(android): record 2026.7.4 Play metadata fix(ci): accept one verified Telegram SUT launch (openclaw#116267) chore(android): prepare 2026.7.4 Play release fix(e2e): align service account state (openclaw#116254) refactor(qa): remove live-channel scenario registries and wrappers (openclaw#115752) fix(ci): let trusted Telegram QA stage runtime (openclaw#116252) fix(plugins): plugin install survives pnpm-only overrides (openclaw#116245) test(qa): recognize internal image completions (openclaw#116234) fix(test): review Codex runtime scan chunks (openclaw#116212) fix(systemd): clear start-limit latch before gateway start (openclaw#116178) fix(security): expose every executable call in plugin scans (openclaw#116222) chore(sdk): repin the API baseline after the resolver signature change test(e2e): delay the draft-proof final answer past the start gate fix(channels): resolve tool progress against the caller's stream mode fix(ci): satisfy docs formatting, lint, and the SDK API baseline test(e2e): add a progress-draft scenario to the mock provider docs(telegram): call out the changed default preview on upgrade refactor(channels): render the progress label as a block, not a line fix(channels): show tool lines under the progress status headline ...
What Problem This Solves
Fixes an issue where operators running
openclaw gateway startcould not recovera systemd-managed gateway after repeated crashes tripped systemd's start-limit
latch.
restartalready cleared that latch, butstartdid not.Fixes #116177.
Why This Change Was Made
Run
systemctl reset-failedbefore bothstartandrestart, while leavingstopunchanged. The change stays in the shared systemd service-action owner,after the existing system-unit ownership guard for user services. No config,
protocol, or new command surface is added.
User Impact
openclaw gateway startnow recovers a crash-looped systemd gateway instead ofreturning a start-limit failure that requires an undocumented manual
systemctl reset-failed.Evidence
Real managed-gateway CLI recovery
Validated on Linux with systemd 255 running as PID 1, using the built OpenClaw
CLI and a real OpenClaw-managed user gateway:
openclaw gateway install --jsoninstalled and enabledopenclaw-gateway.service.reached
failed, withNRestarts=3.systemctl --user start openclaw-gateway.servicereturned nonzero;systemctl statusreportedStart request repeated too quickly.openclaw gateway start --jsonsucceeded and the unit reachedActiveState=active.stracecaptured this ordering from the real CLI:Lifecycle controls on the same managed gateway:
already-running, keptthe same main PID, and issued no
reset-failed.openclaw gateway stop --force --jsonreached inactive and issuedstopwithout
reset-failed.reset-before-start ordering.
Hosted build and Linux proof:
https://github.com/openclaw/openclaw/actions/runs/30511918775
Focused tests
node scripts/run-vitest.mjs src/daemon/systemd.test.tspassed 129/129.Coverage includes:
reset-failedbeforestart;reset-failedbeforestart;reset-failedcannot resolve an unloaded unit;stop;Targeted formatting and
git diff --checkpassed.Autoreview
Structured Codex autoreview on final head
49c4237bcb4found noaccepted/actionable findings. TruffleHog and
git diff --checkwere clean.Remaining proof boundary
The real managed user-scope CLI path is fully exercised. A separate synthetic
system-scope CLI control could not complete because the isolated Testbox root
environment was rejected by OpenClaw's canonical service-target guard. The
system-scope command ordering is covered by the focused unit test and uses the
same
runSystemdServiceActionimplementation.