Skip to content

fix: gateway restart avoids false failure when systemd probe is unavailable - #123069

Merged
steipete merged 2 commits into
mainfrom
steipete/infallible-spence-99dafb
Aug 13, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/infallible-spence-99dafb

Conversation

@steipete

@steipete steipete commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running openclaw gateway restart could receive a failure when the service loaded-state probe could not launch systemctl is-enabled, even though an installed systemd unit existed and the Gateway restart path was otherwise recoverable.

The reported Team Hetzner incident surfaced as Gateway service check failed: Error: systemctl is-enabled unavailable: Command failed during launch or output capture (EACCES) while the Gateway itself recovered with healthy readiness.

Why This Change Was Made

Restart now asks the platform service adapter whether an installed definition exists when the preliminary loaded-state probe is unavailable. Linux uses the canonical systemd scope detector, covering user-scope, system-scope, marker-owned, and existing user-first/dueling semantics. The native restart command and the existing Gateway health/readiness check remain authoritative, so real systemd restart failures and unhealthy restart outcomes still fail.

The redundant post-success loaded-state reprobe was removed from the emitted snapshot path; restart success now carries forward the already established managed/recovered state. Node service adapters preserve their node-specific identity when using the new installation predicate.

AI-assisted: yes (Claude Code and Codex).

User Impact

Operators no longer see a false restart failure solely because systemctl is-enabled could not be launched or captured. Missing service definitions still fail the service check, native service-manager errors still fail the restart, and a Gateway that does not recover health/readiness still fails with the existing diagnostics.

Evidence

  • Regression proven against the pre-fix and initially pushed production paths:
    • node scripts/run-vitest.mjs src/cli/daemon-cli/lifecycle-core.test.ts -t "restarts an installed system-scope service when its loaded-state probe is unavailable"
    • Failed with promise rejected "Error: __exit__:1" instead of resolving at the service loaded-state check.
  • Focused post-fix proof:
    • node scripts/run-vitest.mjs src/cli/daemon-cli/lifecycle-core.test.ts src/cli/daemon-cli/lifecycle.test.ts src/daemon/service.test.ts src/daemon/systemd.test.ts
    • 249 tests passed across the lifecycle, service-adapter, and systemd suites.
    • The regression models a system-scope installation by returning no user-unit command while the adapter-owned installed-definition predicate succeeds.
    • Existing coverage confirms service-manager restart errors and unhealthy Gateway restart outcomes still fail.
  • Static proof:
    • oxfmt --check on all four changed files: clean.
    • Targeted Oxlint on all four changed files: clean.
    • git diff --check: clean.
    • Changed-lane classification: core, coreTests.
  • Independent Codex-backed autoreview: clean after the initial patch and after the system-scope review fix; no accepted/actionable findings.
  • ClawSweeper's initial system-scope finding was addressed by moving installation detection to the platform adapter boundary.
  • Production LOC: +21/-11 (net +10) for the adapter capability and Node identity forwarding. Tests: +27/-0.

Live proof gap: this PR does not restart the operator-owned Team Hetzner Gateway. The exact EACCES condition is covered deterministically at the lifecycle owner boundary; exact-head CI/Testbox evidence will be required before merge.

Allow restart to proceed when the loaded-state probe is unavailable but an installed service definition identifies the native manager. Native restart errors and Gateway health checks remain authoritative.
@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 13, 2026 08:22
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS maintainer Maintainer-authored PR labels Aug 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 13, 2026, 4:27 AM ET / 08:27 UTC.

ClawSweeper review

What this changes

The PR lets Gateway restart continue when a loaded-state probe fails but a service definition can be read, and removes the post-restart loaded-state reprobe.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR needs revision before merge: its fallback recognizes only a parsed user-scope unit, so a supported installed system-scope unit still fails at the unavailable is-enabled probe.

Priority: P2
Reviewed head: 708d3f16a3e8f4e1e1ecb4b78f3e09bde52cdd32

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has a focused stated regression and net-neutral production change, but one supported systemd scope remains unhandled.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused regression remains useful supplemental evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused regression remains useful supplemental evidence.
Evidence reviewed 4 items Fallback misses system-scope installation: The proposed fallback treats readCommand() as proof of installation, but the systemd command reader only reads the user unit path and returns null for a system-only unit.
Systemd supports system-scope units: The loaded-state probe discovers either installed scope, and the native restart path selects and restarts the discovered system-scope unit.
Existing test contract: Current systemd coverage establishes that an enabled system-scope unit is supported, but the new lifecycle test mocks readCommand() as successful and therefore does not exercise that scope boundary.
Findings 1 actionable finding [P2] Recognize system-scope units before bypassing the probe
Security None None.

How this fits together

Gateway restart selects a platform service manager, performs the native restart, then verifies Gateway health. On Linux, systemd supports both user- and system-scope units, while the CLI’s shared lifecycle code decides whether restart may begin.

flowchart LR
  A[Operator runs gateway restart] --> B[CLI lifecycle]
  B --> C[Systemd loaded-state probe]
  C --> D{Installed service detected}
  D --> E[Native systemd restart]
  E --> F[Gateway health check]
  F --> G[Restart result]
Loading

Before merge

  • Recognize system-scope units before bypassing the probe (P2) - readCommand() only parses the user unit under the configured home directory, while isLoaded() and native restart support installed system-scope units. When is-enabled fails for a system-only installation, this condition is false and the command still emits the original service-check failure. Use an adapter-owned installed-definition predicate and cover this scope in the regression test.
  • Complete next step (P2) - A maintainer-owned, protected PR should revise the concrete system-scope gap and add focused coverage before merge.

Findings

  • [P2] Recognize system-scope units before bypassing the probe — src/cli/daemon-cli/lifecycle-core.ts:135-139
Agent review details

Security

None.

PR surface

Source 0, Tests +27. Total +27 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 11 0
Tests 1 27 0 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 38 11 +27

Review metrics

Metric Value Why it matters
Production vs test LOC production +11/-11 (net 0); tests +27/-0 The production change is net-neutral, but the added test mocks the installation signal and misses the supported system-scope path.

Technical review

Best possible solution:

Expose an adapter-owned installed-definition check that covers both systemd scopes, use it only for restart’s probe-unavailable path, and add a regression that combines an unavailable probe with a system-scope unit.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: make the systemd loaded-state probe reject while only a system-scope unit exists; readCommand() resolves only the user path, so this PR still takes the existing failure path.

Is this the best way to solve the issue?

No. The fallback uses a user-unit command parser as an installation predicate even though the service adapter’s systemd operations support system-scope units; installation detection belongs at that adapter boundary.

Full review comments:

  • [P2] Recognize system-scope units before bypassing the probe — src/cli/daemon-cli/lifecycle-core.ts:135-139
    readCommand() only parses the user unit under the configured home directory, while isLoaded() and native restart support installed system-scope units. When is-enabled fails for a system-only installation, this condition is false and the command still emits the original service-check failure. Use an adapter-owned installed-definition predicate and cover this scope in the regression test.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4c60b3b985eb.

Labels

Label changes:

  • add P2: The patch addresses a real but recoverable Gateway-restart failure and currently leaves a supported systemd installation class unfixed.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused regression remains useful supplemental evidence.

Label justifications:

  • P2: The patch addresses a real but recoverable Gateway-restart failure and currently leaves a supported systemd installation class unfixed.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its reported focused regression remains useful supplemental evidence.

Evidence

What I checked:

  • Fallback misses system-scope installation: The proposed fallback treats readCommand() as proof of installation, but the systemd command reader only reads the user unit path and returns null for a system-only unit. (src/daemon/systemd-service-files.ts:46, 4c60b3b985eb)
  • Systemd supports system-scope units: The loaded-state probe discovers either installed scope, and the native restart path selects and restarts the discovered system-scope unit. (src/daemon/systemd-runtime.ts:114, 4c60b3b985eb)
  • Existing test contract: Current systemd coverage establishes that an enabled system-scope unit is supported, but the new lifecycle test mocks readCommand() as successful and therefore does not exercise that scope boundary. (src/daemon/systemd.test.ts:850, 4c60b3b985eb)
  • Feature history: The current split systemd ownership and shared lifecycle consolidation both date to recent service-lifecycle work by the same area contributor. (src/daemon/systemd-scope.ts:169, 8327504c8455)

Likely related people:

  • steipete: Recent merged work consolidated lifecycle ownership and split the current systemd scope implementation. (role: recent service-lifecycle contributor; confidence: high; commits: 8327504c8455, 36554c282008; files: src/cli/daemon-cli/lifecycle-core.ts, src/daemon/systemd-scope.ts, src/daemon/systemd-runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Replace the command-parser fallback with installation detection that covers user and system units.
  • Add a regression for an unavailable loaded-state probe with a system-scope unit.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Move installed-definition detection into the platform service adapter so gateway restart can recover from an unavailable loaded-state probe for both user- and system-scope systemd units.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S and removed size: XS labels Aug 13, 2026
@steipete
steipete merged commit 5ed9bc2 into main Aug 13, 2026
132 checks passed
@steipete
steipete deleted the steipete/infallible-spence-99dafb branch August 13, 2026 09:04
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
…ilable (openclaw#123069)

* fix(cli): avoid false gateway restart failures

Allow restart to proceed when the loaded-state probe is unavailable but an installed service definition identifies the native manager. Native restart errors and Gateway health checks remain authoritative.

* fix(daemon): detect system-scope restart definitions

Move installed-definition detection into the platform service adapter so gateway restart can recover from an unavailable loaded-state probe for both user- and system-scope systemd units.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant