-
Couldn't load subscription status.
- Fork 89
Support AGENT_CONFIG from volume mounts and remove secret logging #9243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthroughnoobaa_init.sh now early-exits if an existing Changes
Sequence Diagram(s)sequenceDiagram
participant Script as noobaa_init.sh
participant FS as Filesystem
participant ENV as Environment
participant JQ as jq
participant DEC as base64-decode
Script->>FS: stat / check `agent_conf.json`
alt exists
FS-->>Script: file present
Script->>Script: exit (early)
else not exists
Script->>ENV: read AGENT_CONFIG or file at AGENT_CONFIG_PATH (/etc/agent-config/agent_config)
alt AGENT_CONFIG empty
ENV-->>Script: empty/missing
Script->>Script: exit with "missing AGENT_CONFIG" error (mentions path)
else AGENT_CONFIG present
ENV-->>Script: config payload
Script->>JQ: attempt JSON parse
alt jq success
JQ-->>Script: valid JSON
Script->>FS: write `agent_conf.json`
else jq fails
JQ-->>Script: invalid JSON
Script->>DEC: attempt base64 decode
alt decode success
DEC-->>Script: decoded JSON
Script->>FS: write `agent_conf.json`
else decode fails
DEC-->>Script: decode failed
Script->>Script: exit with "invalid AGENT_CONFIG format" error
end
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
config.js(1 hunks)src/deploy/NVA_build/noobaa_init.sh(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
src/deploy/NVA_build/noobaa_init.sh
[warning] 128-128: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build Noobaa Image
- GitHub Check: run-package-lock-validation
- GitHub Check: run-jest-unit-tests
🔇 Additional comments (1)
config.js (1)
245-250: LGTM! Clean implementation following existing patterns.The AGENT_CONFIG section follows the same pattern as other secret configurations (JWT_SECRET, SERVER_SECRET). Using
_get_data_from_fileis appropriate and handles missing files gracefully by returning undefined, which the shell script later validates.
c5de7b9 to
17b14ea
Compare
17b14ea to
fb12872
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/deploy/NVA_build/noobaa_init.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: run-package-lock-validation
- GitHub Check: Build Noobaa Image
- GitHub Check: run-jest-unit-tests
🔇 Additional comments (1)
src/deploy/NVA_build/noobaa_init.sh (1)
129-135: Variable quoting and early-exit validation are properly addressed. ✓Lines 132–135 now correctly quote
${AGENT_CONFIG}in the test and provide a clear error message when the configuration is missing. Both past quoting concerns have been resolved.
fb12872 to
3297bd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Signed-off-by: Aayush Chouhan <[email protected]>
3297bd8 to
b9bdfcf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/deploy/NVA_build/noobaa_init.sh (1)
138-143: Consider validating base64-decoded JSON before writing.The current flow attempts JSON parsing first, then falls back to base64 decoding. However, after a successful base64 decode (line 139), the script doesn't validate that the decoded content is valid JSON. If
AGENT_CONFIGis valid base64 that decodes to invalid JSON, the script will succeed but write corrupted config. The agent will then fail downstream.Consider piping the decoded output through
jqvalidation before writing to ensure end-to-end correctness.Proposed diff:
if ! echo "${AGENT_CONFIG}" | jq . >"$AGENT_CONF_FILE" 2>/dev/null; then - openssl enc -base64 -d -A <<<"${AGENT_CONFIG}" >"$AGENT_CONF_FILE" || { + if ! openssl enc -base64 -d -A <<<"${AGENT_CONFIG}" | jq . >"$AGENT_CONF_FILE" 2>/dev/null; then echo "AGENT_CONFIG format is invalid. AGENT_CONFIG must be valid JSON or base64 encoded JSON. Exit" exit 1 - } + fi fi
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/deploy/NVA_build/noobaa_init.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build Noobaa Image
- GitHub Check: run-jest-unit-tests
- GitHub Check: run-package-lock-validation
🔇 Additional comments (1)
src/deploy/NVA_build/noobaa_init.sh (1)
123-144: Changes look good—previous issues addressed and PR objectives met.The function now correctly:
- Supports reading
AGENT_CONFIGfrom volume-mounted secrets viaAGENT_CONFIG_PATH(line 130)- Removes unconditional logging of the raw config (no direct
echoofAGENT_CONFIG)- Quotes variables properly (line 132, 139)
- Handles errors from
opensslbase64 decode (lines 139–142)- Provides clear error messages linking to expected sources (lines 133, 140)
All three issues from previous review comments are resolved.
Describe the Problem
AGENT_CONFIGwas supported as environment variable, not as volume-mounted secrets. Also the agent logs exposed sensitive configuration data.Explain the Changes
Issues: Fixed #xxx / Gap #xxx
Testing Instructions:
Summary by CodeRabbit