Skip to content

fix: resolve OpenShell runner infinite recursion and enable local images#215

Closed
squizzi wants to merge 6 commits into
mainfrom
squizzi/fix-kind-rebuild-target
Closed

fix: resolve OpenShell runner infinite recursion and enable local images#215
squizzi wants to merge 6 commits into
mainfrom
squizzi/fix-kind-rebuild-target

Conversation

@squizzi

@squizzi squizzi commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes three issues with OpenShell runner in kind-local development: infinite recursion bug, local image pull failures, and adds reload target for faster iteration. Merged with PR #214 for comprehensive recursion protection.

Changes

  1. Infinite recursion fix: The wrapper was infinitely recursing and accumulating --bare arguments until hitting ARG_MAX. Combined two fixes - removes npm symlink before copying wrapper, calls claude.exe directly, AND includes guard file protection from PR fix(runner): prevent infinite recursion in openshell claude wrapper and move inference env vars to sandbox level #214
  2. Local images: Added kustomize patch to set localhost/ prefix for runner images in kind-local, enabling imagePullPolicy: IfNotPresent
  3. Gateway pull policy: Configured OpenShell gateway to use image_pull_policy = "IfNotPresent" for sandbox pods
  4. Reload targets: Refactored kind-rebuild to use individual reload targets, added kind-reload-runner-openshell for fast iteration

Testing

  • Rebuild OpenShell runner: make kind-reload-runner-openshell
  • Verify no infinite recursion in sandbox sessions
  • Confirm local images load without registry pull attempts

🤖 Generated with Claude Code

bsquizz and others added 6 commits June 30, 2026 19:04
The wrapper is installed as /usr/local/bin/claude, so when Claude Code
spawns subagents that invoke `claude` by name, PATH resolves back to the
wrapper causing infinite recursion. Add a re-entry guard that execs the
real binary directly on subsequent invocations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…evention

The env var approach doesn't work because the OpenShell sandbox supervisor
spawns each command in a clean environment that does not inherit exports.
Switch to a /tmp file guard that persists across invocations within the
same sandbox instance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from the claude wrapper
script into the reconciler's buildSandboxEnv so every tool in the
sandbox gets them, not just processes launched through the wrapper.
Remove HTTPS_PROXY, NO_PROXY, and NODE_EXTRA_CA_CERTS from the wrapper
since those are already set by the reconciler and supervisor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit addresses three related issues with the OpenShell runner in
kind-local development:

1. **Fork bomb fix**: The openshell-claude-wrapper.sh script was
   recursively calling itself due to npm's global install creating a
   symlink at /usr/local/bin/claude. When the Dockerfile copied the
   wrapper to that location, it followed the symlink and overwrote
   claude.exe itself, causing infinite recursion. Fixed by removing the
   npm symlink before copying the wrapper, and updating the wrapper to
   call claude.exe directly.

2. **Local image support**: Added control-plane-local-images-patch.yaml
   to override RUNNER_IMAGE, OPENSHELL_RUNNER_IMAGE, and MCP_IMAGE env
   vars with localhost/ prefix for kind-local deployments. This triggers
   imagePullPolicy=IfNotPresent via existing logic in kube_reconciler.go.

3. **Gateway imagePullPolicy**: OpenShell gateway was hardcoded to
   imagePullPolicy=Always for sandbox pods, causing pull failures for
   localhost/ images. Added image_pull_policy = "IfNotPresent" to the
   gateway.toml configuration.

4. **kind-reload targets**: Refactored kind-rebuild to call individual
   kind-reload-* targets instead of build-all + blanket restart. Added
   new kind-reload-runner-openshell target for rapid iteration on the
   OpenShell runner during development.

Changes:
- Makefile: Refactored kind-rebuild, added kind-reload-runner-openshell
- Dockerfile.openshell: Remove npm symlink before COPY wrapper
- openshell-claude-wrapper.sh: Call claude.exe directly (not /opt/claude/bin/claude)
- gateway/configmap.yaml: Set image_pull_policy = "IfNotPresent"
- kind-local overlay: Add control-plane-local-images-patch.yaml

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Kyle Squizzato <kysquizz@redhat.com>
…ges in kind

This commit addresses three related issues with the OpenShell runner in
kind-local development:

1. **Infinite recursion fix**: The openshell-claude-wrapper.sh script was
   infinitely recursing, calling itself and accumulating --bare arguments
   until hitting ARG_MAX. This occurred because npm's global install created
   a symlink at /usr/local/bin/claude. When the Dockerfile copied the wrapper
   to that location, it followed the symlink and overwrote claude.exe itself.
   Fixed by removing the npm symlink before copying the wrapper, and updating
   the wrapper to call claude.exe directly. Also merged guard file protection
   from PR #214.

2. **Local image support**: Added control-plane-local-images-patch.yaml
   to override RUNNER_IMAGE, OPENSHELL_RUNNER_IMAGE, and MCP_IMAGE env
   vars with localhost/ prefix for kind-local deployments. This triggers
   imagePullPolicy=IfNotPresent via existing logic in kube_reconciler.go.

3. **Gateway imagePullPolicy**: OpenShell gateway was hardcoded to
   imagePullPolicy=Always for sandbox pods, causing pull failures for
   localhost/ images. Added image_pull_policy = "IfNotPresent" to the
   gateway.toml configuration.

4. **kind-reload targets**: Refactored kind-rebuild to call individual
   kind-reload-* targets instead of build-all + blanket restart. Added
   new kind-reload-runner-openshell target for rapid iteration on the
   OpenShell runner during development.

Changes:
- Makefile: Refactored kind-rebuild, added kind-reload-runner-openshell
- Dockerfile.openshell: Remove npm symlink before COPY wrapper
- openshell-claude-wrapper.sh: Call claude.exe directly (not /opt/claude/bin/claude)
- gateway/configmap.yaml: Set image_pull_policy = "IfNotPresent"
- kind-local overlay: Add control-plane-local-images-patch.yaml

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Kyle Squizzato <kysquizz@redhat.com>
@squizzi squizzi force-pushed the squizzi/fix-kind-rebuild-target branch from 723d5c6 to 4aa86a8 Compare June 30, 2026 23:45
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ SDD Preflight — Managed Paths Modified

This PR modifies files in SDD-managed component(s). These components are migrating to Spec-Driven Development.

File Component Mode
components/runners/ambient-runner/Dockerfile.openshell runner warn
components/runners/ambient-runner/openshell-claude-wrapper.sh runner warn

No action required — these components are in warn mode. Consider using the component's agent workflow for future changes.

📖 Specs: Runner Spec · Runner Constitution

@squizzi squizzi changed the title fix: resolve OpenShell runner fork bomb and enable local images fix: resolve OpenShell runner infinite recursion and enable local images Jun 30, 2026
@squizzi

squizzi commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of merging with #214

@squizzi squizzi closed this Jun 30, 2026
@squizzi squizzi deleted the squizzi/fix-kind-rebuild-target branch June 30, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants