Skip to content

feat(docker): support custom parameters via OPENVIKING_CONSOLE_PARAMETERS in console entrypoint#1959

Open
kuronekosaiko wants to merge 1 commit into
volcengine:mainfrom
kuronekosaiko:patch-1
Open

feat(docker): support custom parameters via OPENVIKING_CONSOLE_PARAMETERS in console entrypoint#1959
kuronekosaiko wants to merge 1 commit into
volcengine:mainfrom
kuronekosaiko:patch-1

Conversation

@kuronekosaiko
Copy link
Copy Markdown

Description

This PR introduces the OPENVIKING_CONSOLE_PARAMETERS environment variable to the console entrypoint script.

The Problem:
Currently, several guides (e.g., 05-observability.md, 11-oauth.md) and design docs (mcp-oauth2-1.md) explicitly state that users should start the console with the --write-enabled flag to perform administrative actions such as adding resources or managing tenants. However, there is currently no way to pass this flag when running OpenViking via Docker or Docker Compose, effectively locking containerized users into a "read-only" mode.

The Solution:
By adding support for OPENVIKING_CONSOLE_PARAMETERS, users can now inject --write-enabled (or any other future flags) into the bootstrap process via their docker-compose.yml or docker run environment settings.

Related Issue

Type of Change

  • New feature (non-breaking change that adds functionality)

Changes Made

  • Added CONSOLE_PARAMETERS variable to the entrypoint script, defaulting to an empty string.
  • Implemented a conditional log output to only display "Starting console with extra parameter: ..." when the variable is non-empty, keeping logs clean.
  • Appended ${CONSOLE_PARAMETERS} to the python -m openviking.console.bootstrap execution command.

Testing

  • Manual testing completed
    • Case 1: Set OPENVIKING_CONSOLE_PARAMETERS="--write-enabled". Verified the console starts with write permissions and logs reflect the parameter.
    • Case 2: Unset the variable. Verified the console starts normally without trailing empty strings in the logs.
  • I have tested this on the following platforms:
    • Linux (Docker environment)

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation (Implementation now matches documentation)
  • My changes generate no new warnings

Additional Notes

  • This change ensures consistency between the manual Python execution described in the guides and the containerized deployment path.
  • ✨ Assisted by Gemini

Allow passing extra arguments to openviking console via OPENVIKING_CONSOLE_PARAMETERS in entrypoint script.
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 75
🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Word Splitting/Globbing Bug

Unquoted ${CONSOLE_PARAMETERS} causes incorrect parsing of parameters containing spaces or wildcards. For example, OPENVIKING_CONSOLE_PARAMETERS="--log-path /path with spaces" will be split into multiple invalid arguments.

${CONSOLE_PARAMETERS} &

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix parameter parsing with bash array

Use a bash array with xargs to properly parse ${CONSOLE_PARAMETERS} while respecting
quoted spaces and avoiding unintended word splitting/glob expansion. Also update the
log message to use plural "parameters" since multiple may be provided.

docker/openviking-console-entrypoint.sh [9-166]

 CONSOLE_PARAMETERS="${OPENVIKING_CONSOLE_PARAMETERS:-""}"
+# Parse parameters into array while respecting quotes
+read -ra console_params_array <<< "$(xargs printf '%s\n' <<< "${CONSOLE_PARAMETERS}")"
 ...
-if [ -n "${CONSOLE_PARAMETERS}" ]; then
-    echo "[openviking-console-entrypoint] Starting console with extra parameter: ${CONSOLE_PARAMETERS}"
+if [ ${#console_params_array[@]} -gt 0 ]; then
+    echo "[openviking-console-entrypoint] Starting console with extra parameters: ${CONSOLE_PARAMETERS}"
 fi
 ...
 python -m openviking.console.bootstrap \
     --host "${CONSOLE_HOST}" \
     --port "${CONSOLE_PORT}" \
     --openviking-url "${SERVER_URL}" \
-    ${CONSOLE_PARAMETERS} &
+    "${console_params_array[@]}" &
Suggestion importance[1-10]: 7

__

Why: The suggestion addresses potential word splitting and glob expansion issues when using ${CONSOLE_PARAMETERS} unquoted, improving robustness for parameters with spaces or special characters. It also updates the log message to use plural "parameters" for accuracy.

Medium

@kuronekosaiko
Copy link
Copy Markdown
Author

The suggestion to use Bash arrays is technically incompatible with this environment. The image is python:3.13-slim-trixie, where /bin/sh is Dash. Dash does not support arrays, read -a, or here-strings (<<<).

Adopting the suggested code would cause the container to crash with a Syntax error. The current unquoted expansion is the standard POSIX-compliant way to handle multiple flags in a lightweight entrypoint.

✨ Assisted by Gemini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant