Repository navigation
Conversation
When solrSecurity.probesRequireAuth is set, the generated probe command piped the output of 'solr api' through 'grep -v JAVA_TOOL_OPTIONS' to keep the JVM's "Picked up JAVA_TOOL_OPTIONS: ..." line, which contains the basic auth credentials, out of the probe output that Kubernetes surfaces in pod events. A pipeline exits with the status of its last command, so the exit code of 'solr api' was discarded and grep's 0 was reported instead. The probes therefore always succeeded, and a pod whose credentials Solr rejects with a 401 was still reported as healthy and ready. Capture the output in a variable instead of piping, save the exit status, then filter and exit with the saved status. POSIX sh only, so this does not rely on 'pipefail', which dash does not support. Fixes apache#799
| probeCommand = fmt.Sprintf( | ||
| "probe_output=$(JAVA_TOOL_OPTIONS=%q %s 2>&1); probe_status=$?; echo \"$probe_output\" | grep -v JAVA_TOOL_OPTIONS; exit $probe_status", | ||
| strings.Join(javaToolOptions, " "), solrApiCommand) |
There was a problem hiding this comment.
Found this as well and it seems more straightforward to solve this via bin/solr env vars:
SOLR_AUTH_TYPE=basic SOLR_AUTHENTICATION_OPTS="-Dbasicauth=$(cat <dir>/username):$(cat <dir>/password)" solr api -get "<url>"
Passing -Dbasicauth via JAVA_TOOL_OPTIONS also seems to break on Solr 10; and it avoids the "Picked up JAVA_TOOL_OPTIONS" banner
|
🤖 Thanks @danielmeint — you're right, and for a sharper reason than "
Verified against authenticated Solr instances (
Every working row exits 0 on success and 1 on a wrong password, with no banner and no credentials in the output — so #799 is fixed by construction, with no output filter and no saved-exit-status dance. Plan, assuming this merges after #827:
Optional, in the same PR or later:
Worth noting either way: the credentials stop reaching the probe output that Kubernetes surfaces in pod events, which was the more serious exposure in #799 — argv is readable only with a shell in the pod, pod events with namespace read access. |
When solrSecurity.probesRequireAuth is set, the generated probe command piped the output of 'solr api' through 'grep -v JAVA_TOOL_OPTIONS' to keep the JVM's "Picked up JAVA_TOOL_OPTIONS: ..." line, which contains the basic auth credentials, out of the probe output that Kubernetes surfaces in pod events.
A pipeline exits with the status of its last command, so the exit code of 'solr api' was discarded and grep's 0 was reported instead. The probes therefore always succeeded, and a pod whose credentials Solr rejects with a 401 was still reported as healthy and ready.
Capture the output in a variable instead of piping, save the exit status, then filter and exit with the saved status. POSIX sh only, so this does not rely on 'pipefail', which dash does not support.
Fixes #799