Skip to content

Pass start.sh arguments on to the python script - #3

Merged
8ryn merged 2 commits into
mainfrom
fix-issue-2-script-args
Oct 2, 2026
Merged

8ryn merged 2 commits into
mainfrom
fix-issue-2-script-args

Conversation

@gilesknap

@gilesknap gilesknap commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Problem

There is no way to give the IOC's python script command line arguments from a service's values.yaml. ioc/start.sh drops its own arguments, and the stdio-socket console wrap re-runs start.sh with none.

What changed

  • ioc/start.sh forwards "$@" to python ${STARTUP_PYTHON} and to an override config/start.sh.
  • stdio-socket takes a single command string, which it runs through a shell and pptty, so quoting arguments into that string is fragile. Instead the outer start.sh saves the arguments in IOC_ARGS (quoted with printf %q), and the inner start.sh restores them with eval set --.
  • README: shows how to add arguments in values.yaml.

The issue suggests replacing CMD with an ENTRYPOINT. I left the Dockerfile alone because the ioc-instance chart sets command: [bash, -c] and args: [/epics/ioc/start.sh], which override both ENTRYPOINT and CMD. Under helm the arguments therefore come from args:, like this:

ioc-instance:
  args:
    - /epics/ioc/start.sh "$@"
    - start.sh        # becomes $0 of the bash -c script
    - --my-option
    - value

An ENTRYPOINT would also change what docker run <image> bash and the devcontainer do, so it seemed better as a separate decision.

Testing

  • Ran the new start.sh in bash with a stub config/main.py that prints sys.argv, and a stub stdio-socket that runs its command string with sh -c like the real one does:
    • without KUBERNETES_PORT: --foo "two words" "it's" arrive unchanged
    • with KUBERNETES_PORT (through the wrap): the same, plus a literal '$HOME' that is not expanded
    • with no arguments: sys.argv[1:] == []
    • an override config/start.sh receives the arguments
  • Not tested: building the container image, or running under the real stdio-socket/pptty in a cluster.

Fixes #2

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jd9gGzEQubx2j1kD6Q2s8a

Summary by CodeRabbit

  • New Features
    • Python startup scripts now receive arguments supplied through supported start.sh configurations, including when running behind the Kubernetes standard I/O wrapper.
  • Documentation
    • Added examples explaining how to pass arguments through direct and default command configurations.

Arguments given to ioc/start.sh are now forwarded to the startup python
script and to an override config/start.sh. stdio-socket only takes a
single command string, so the arguments are carried across the console
wrap in IOC_ARGS (shell quoted with printf %q) and restored after.

Fixes #2

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jd9gGzEQubx2j1kD6Q2s8a
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f4683f20-5c83-4882-bca5-75162b6fbf8e

📥 Commits

Reviewing files that changed from the base of the PR and between 42a42ba and 9b6efe9.

📒 Files selected for processing (2)
  • README.md
  • ioc/start.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The startup script now preserves supplied arguments across the stdio-socket wrapper and passes them to the configured startup script or Python startup script. The README documents two command configurations for passing arguments.

Changes

Startup argument forwarding

Layer / File(s) Summary
Preserve and forward startup arguments
ioc/start.sh, README.md
ioc/start.sh stores and restores arguments around the stdio-socket wrapper and passes them to the configured startup script or Python startup script. The README documents two ways to provide arguments.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9b6ef

The argument-forwarding change has no established merge blocker in the supplied evidence. Normal validation remains appropriate.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #2 requires arguments from chart configuration to reach the Python entrypoint. ioc/start.sh now passes "$@" to the Python script and to config/start.sh. The stdio-socket path preserves arg…
Out of Scope Changes check ✅ Passed The changed files are limited to ioc/start.sh and README.md. The script changes implement argument forwarding for the requested startup paths. The README changes document the required chart config…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: forwarding start.sh arguments to the Python startup script.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

Rename IOC_ARGS to _STDIO_IOC_ARGS so the eval'd hand-off variable reads as
internal, and document the simpler values.yaml form that overrides the
chart's command to run start.sh directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jd9gGzEQubx2j1kD6Q2s8a
@gilesknap

Copy link
Copy Markdown
Member Author

Independent review by a Claude Fable agent

  • nit: README should document the simpler command: [/epics/ioc/start.sh] + args: [...] values.yaml form instead of only the bash -c "$@" trick -> Fixed in 9b6efe9 (documented as the primary form; the bash -c form kept as an alternative)
  • nit: IOC_ARGS is an eval'd, public-looking variable honoured whenever set -> Fixed in 9b6efe9 (renamed to _STDIO_IOC_ARGS and commented as internal only)

Review and replies by Claude Code.

@gilesknap

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@8ryn

8ryn commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

I have tested this implementation on Pollux and it works as described and solves the issue.

@8ryn
8ryn merged commit 64fda11 into main Oct 2, 2026
7 checks passed
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.

Allow command line arguments to be passed to the python script

2 participants