Skip to content

fix: let updates stop a Gateway that OpenClaw reran under a compatible Node - #203152

Merged
steipete merged 2 commits into
mainfrom
codex/issue-202954
Nov 21, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/issue-202954

Conversation

@steipete

@steipete steipete commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Refs #202954
Related: #202642, #202633

What Problem This Solves

When the Node.js that a Linux systemd Gateway service starts with fails the Gateway's runtime check, OpenClaw reruns the Gateway under a compatible Node it finds, such as its private runtime in ~/.openclaw/tools/cli-node. The service's main process is then that launcher, and the Gateway that actually serves is its child. Every update of such a service fails with managed-service-stop-failed ("Gateway process changed during maintenance drain"), although the Gateway is healthy. Automatic updates retry this every one to two hours. One reporter has about 330 failed runs, each taking ~10 minutes and leaving a ~1.9 GiB snapshot. 2026.10.8 and 2026.10.9 Gateways on Node 24 below 24.22.1 are in exactly this layout, and so is any release whose service Node is below its supported floor.

User Impact

Updates succeed again for Gateways that OpenClaw reran under a compatible Node. The refusal comes from the installed updater's stop, before the package swap. The fix therefore applies to updates driven by a release that contains it. Installs already stuck on an older release need the one-time step posted on #202954: refresh the service definition from a CLI on a supported Node, or use the manual npm hop.

Why This Change Was Made

Maintenance drain required the PID the Gateway reports to equal the service's main PID, which is never true in this layout. The restart path already treats a port listener whose parent is the service's main process as the service's own Gateway (listenerOwnedByRuntimePid). Drain now accepts the same relation, with a stricter rule: every listener on the Gateway port must be the reporting process, and its parent must be the service's main PID. Stopping the unit stops both processes. An unrelated listener, or a child of another parent, is still refused.

Evidence

Regression test. update-command-service-drain.test.ts covers the normal and explicit drain for the child case, plus the two refusals. On base, the two child cases fail (2 failed / 62 passed). With the fix, 87 tests pass across the drain, native drain and resident-restart suites.

Live proof. Run on Crabbox Linux against a systemd user unit, with a private patched Node 24.22.1 in ~/.openclaw/tools/cli-node. The resident layout was captured before each update: MainPID is the launcher, and the port listener is its child on the private Node.

Lane Unit Node From → To (driver) Result
reporter path 24.21.0 2026.10.9 → 2026.11.6 fails: Gateway process changed during maintenance drain; Gateway left on 10.9
main base 24.21.0 2026.10.9 → main fails (10.9 driver)
main base 24.15.0 main → main (CLI) fails: same refusal
main base 24.15.0 main → main (Gateway update.run) fails: same refusal
fix 24.15.0 fix → fix (CLI) passes: drained, stopped and restarted; /readyz 200 on target, twice
workaround 24.21.0 10.9, openclaw gateway install --force from a patched-Node CLI, then → 11.6 passes
manual npm hop 24.21.0 10.9 → 11.6 per update-methods.md passes, all steps rc=0

A separate pre-existing problem showed up during this proof: main-driven Gateway update.run updates fail after the stop, with or without this layout and without this patch. It will be tracked separately and is unrelated to this change.

Checks. Format and lint are clean. $autoreview is scoped-clean, and an independent Codex read-only review reported no findings.

…r Node

A service whose Node is unsupported or lacks a recommended security patch
reruns the Gateway under a compatible Node as a child of the launcher, so the
service's main PID never equals the PID the resident reports. Maintenance drain
refused every such update with 'Gateway process changed during maintenance
drain'. Accept the resident when every Gateway port listener is that process
and its parent is the service's main process, matching restart port ownership.

Refs #202954
@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S labels Nov 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets maintenance drain recognize a Gateway running as the service launcher's direct child under a recovered Node runtime.

Example: systemd tracks launcher PID 42 while Gateway PID 43 serves port 18789 under a compatible Node.

  • Before: Maintenance drain rejects PID 43 because it differs from the service's main PID.
  • After: Drain accepts PID 43 when every attributed local listener belongs to it and has parent PID 42.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-supported, but the claimed live result is not inspectable and broad validation has not run.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Automatic and manual updates fail when OpenClaw's own runtime recovery leaves the healthy Gateway serving as the native launcher's child.
Reason: The maintainer-authored direction restores the supported update workflow using existing ownership facts, with no new public configuration or contract.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it narrowly repairs a current managed-update failure, and inspection found no actionable code defect.

Priority: P1
Reviewed head: b76045cdea59e87d6b5c17031e46c199621163bb

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted terminal output or logs showing the launcher/child service successfully completing the changed stop and update path, including a latest-stable upgrade with settings and data intact; redact IPs, keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The update maintenance owner connects to the local Gateway, verifies its identity and lifecycle readiness, and invokes the existing native service stop.

flowchart LR
  A[Update maintenance] --> B[Inspect native service]
  B --> C[Query local Gateway]
  C --> D[Verify PID and listener parent]
  D --> E[Drain lifecycle work]
  E --> F[Stop native service]
Loading

Technical review

Best possible solution:

Keep resident recognition in the existing maintenance owner and accept the verified serving child while retaining native service identity and lifecycle safeguards.

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

Source establishes the failure: runtime recovery creates a serving child, while current-main maintenance requires its reported PID to equal the launcher's native service PID; the linked report observes that layout.

Is this the best way to solve the issue?

This is a focused repair of resident identity recognition: one reused local predicate covers the affected paths without introducing state, retries, options, or another service owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 314a47d16d80.

Provenance checked

  • Maintenance resident identity and shutdown budgets keeps the original intent (54abbae: Maintenance verifies the resident before trusting its shutdown budget and draining it, preserving operator policy and reported write custody.)
  • Explicit suspension and committed handoff keeps the original intent (1c88dd2: Immutable activation requires a verified process target, current suspension lease, and committed shutdown handoff.)
  • Stale-runtime listener ownership keeps the original intent (5161477: Recognized stale residents may bypass unusable RPC only with verified service, lock, and listener attribution.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 54abbae adds src/cli/update-cli/update-command-service-drain.ts:116 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 54abbae585bc; files: src/cli/update-cli/update-command-service-drain.ts)
  • Jason (Json): Raw commit ff75829 adds src/cli/update-cli/update-command-service-resident-restart.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ff7582981434; files: src/cli/update-cli/update-command-service-resident-restart.ts)
  • Dallin Romney: Raw commit 14886e4 adds src/cli/update-cli/update-command-service-drain.ts:227 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 14886e46e823; files: src/cli/update-cli/update-command-service-drain.ts)

PR surface

Source +22, Tests +27, Docs +8. Total +57 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 25 3 +22
Tests 1 28 1 +27
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 61 4 +57

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #202954
Summary: This PR repairs the stable launcher/serving-child mismatch reported in the canonical issue; the earlier installation-replacement retry addresses a distinct process change.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P1: The affected managed installation repeatedly fails updates while its Gateway remains healthy, preventing users from receiving subsequent fixes.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The affected managed installation repeatedly fails updates while its Gateway remains healthy, preventing users from receiving subsequent fixes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 21, 2026, 11:03 AM ET / 16:03 UTC.

@steipete
steipete marked this pull request as ready for review November 21, 2026 17:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T17:12:01.751237Z 216b5b8 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit a27f0c3 into main Nov 21, 2026
263 of 265 checks passed
@steipete
steipete deleted the codex/issue-202954 branch November 21, 2026 18:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…e Node (openclaw#203152)

* fix(update): drain a Gateway that runtime recovery reran under another Node

A service whose Node is unsupported or lacks a recommended security patch
reruns the Gateway under a compatible Node as a child of the launcher, so the
service's main PID never equals the PID the resident reports. Maintenance drain
refused every such update with 'Gateway process changed during maintenance
drain'. Accept the resident when every Gateway port listener is that process
and its parent is the service's main process, matching restart port ownership.

Refs openclaw#202954

* docs(update): runtime recovery reruns the Gateway only when its Node fails admission

Co-authored-by: Peter Steinberger <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…e Node (#203152)

* fix(update): drain a Gateway that runtime recovery reran under another Node

A service whose Node is unsupported or lacks a recommended security patch
reruns the Gateway under a compatible Node as a child of the launcher, so the
service's main PID never equals the PID the resident reports. Maintenance drain
refused every such update with 'Gateway process changed during maintenance
drain'. Accept the resident when every Gateway port listener is that process
and its parent is the service's main process, matching restart port ownership.

Refs #202954

* docs(update): runtime recovery reruns the Gateway only when its Node fails admission

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit a27f0c3)
Release-companions: #204017 is a separate Linux release-install Doctor fallback when lsof/ss cannot attribute listeners; it is not required for this attributed-listener runtime-recovery case. #203486 pnpm recovery, #201668 data-risk repair, and #202591 snapshot cleanup only overlap documentation; #203236 is independent auto-update retry policy. The neighboring native drain suite remains unchanged.
Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot added a commit that referenced this pull request Nov 24, 2026
…e Node (#203152)

Baseline adaptation: Use the listener PID and immediate service parent for the launcher fallback, preserving resident identity and stop authority checks.

(cherry picked from commit a27f0c3)

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#203236)

* fix(update): back off identical automatic update failures

Automatic campaigns retried a target that kept failing the same way before
activation (for example managed-service-stop-failed) every hour forever. One
install accumulated ~330 failed runs, each costing a validation pass and a
candidate state snapshot.

The campaign already used the newest terminal run rows as its durable backoff
fact for repeated activation failures. Extend that streak to every identical
failure class for the same target: keep the hourly first retry, then wait 2, 4,
8 and 16 hours and once a day after six. A new target, a success, or a manual
update breaks the streak. No new state, store, or config.

Refs #202954

* test(update): assert backoff expiry before the new-candidate reset

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit adc0876)

Companion audit: #203194 and #203497 change update architecture and are not needed by the backoff; #203274 is chat reset cleanup, #203528 is node credential repair, and #203578 adds a separate database custody refusal. #203152 addresses stopping a Gateway after a Node runtime respawn, not pre-mutation outcome history; no dependency on that process-shutdown repair.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant