Repository navigation
fix(docker): write the config template only when the server starts - #1767
Merged
Merged
Conversation
Both image entrypoints generated config.jsonc and printed 'Edit ... restart the container' before any command, including llm-rosetta ext install and llm-rosetta gateway --help. The template belongs to the default start: the default CMD, an argument list that holds only options, and an explicit serve (also gateway serve). Every other command runs without it. The config directory is CONFIG_DIR (default /config), which the shell tests set to a temporary directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Part of #1704. Found while running the new surface in the Docker image on the build host (llm-rosetta-03's frozen and containerised build check). Both image entrypoints (
docker/entrypoint.shfor the Python image,docker/entrypoint-binary.shfor the binary image) generated/config/config.jsoncand printed "Edit /config/config.jsonc with your API keys and restart the container." before any command, sollm-rosetta gateway --help,llm-rosetta ext listandllm-rosetta ext install acmein a fresh container wrote a template and told the operator to restart something that was not running.The template belongs to the start of the server. Both scripts now decide with one function,
starts_server: it is true for the default CMD (llm-rosetta-gateway --config ... --host ...), for an argument list that holds only options (the existingdocker run IMG --port 9000shorthand), and for an explicitserve, asllm-rosetta-gateway serve,llm-rosetta serveorllm-rosetta[-gateway] gateway serve. Option values (--config serve.jsonc) are skipped so they are not read as a verb. Every other command,init,add,ext ...,gateway usage ..., a barellm-rosetta, a shell, runs without the template and without the message. First-run behaviour for the server is unchanged.To make the scripts testable the config directory is a variable,
CONFIG_DIR(default/config, so nothing changes in an image; the HOME fallback for an arbitrary uid is$CONFIG_DIR/home, which is/config/homeby default).Checked on the real image, built on the build host from master 185a282 plus this change:
docker run IMG llm-rosetta gateway --helpand... ext listprint their output with no template and no restart note; the default CMD with no/configstill prints "No config.jsonc found in /config, generating template... Edit /config/config.jsonc ... restart the container."Tests (
tests/test_docker_entrypoints.py, new, 65 cases, no Docker needed): both scripts run undershwith stub executables onPATHandCONFIG_DIRin a temporary directory. 10 server-start argv forms (default CMD, option-only,--config init.jsoncas a value,servein each spelling) write the template when there is no config and leave an existing config alone; 12 one-off argv forms (gateway --help,gateway init,gateway usage,ext list,ext install, barellm-rosetta,llm-rosetta gateway,llm-rosetta-gateway init,--config serve.jsonc init,ext list,gateway init, a shell) print no template message and run only the command itself (noinitbefore it); and the Python entrypoint runsinitfirst and then the given command in order. The old scripts fail 45 of them (they also hard-code/config, so the temporary directory cannot reach them; the red is the behaviour plus that). The tests skip whendocker/is not part of the checkout (the remote test runner does not sync it). No test deleted. Package-level edges: none.Risk tier (tick one)
Verification
make lintandmake testpass. Result: ruff clean; the new module 65 passed locally; a full run on the remote runner (before the skip guard for a missingdocker/was added) had the 4 known remote-runner failures, the import-time-clocktest_usagecases, onetest_updatesfailure and onetest_unknown_modelerror fromOSError: [Errno 24] Too many open fileson the runner, and 43 failures in the new module becausedocker/is not synced there; none reproduces locally, and GitHub's CI is the gatetyclean (python scripts/dev/run_ty.py; new diagnostics: 0): the commit hook passedpython scripts/dev/check_move.py origin/master --markdown): not a pure movepython scripts/dev/pr_overlap.pyshows no open PR on the same filesAI disclosure
Co-authored-byAI tags are in the commits.Skipped hooks
none