Skip to content
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

Fix configsvr with user/pass env vars on 5.0 & 6.0 #600

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions 4.2/docker-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions 4.4/docker-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions 5.0/docker-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions 6.0/docker-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,21 @@ _parse_config() {
cat >&2 "$jsonConfigFile"
exit 1
fi
jq 'del(.systemLog, .processManagement, .net, .security, .replication)' "$jsonConfigFile" > "$tempConfigFile"
jq 'del(.systemLog, .processManagement, .net, .security, .replication, .sharding)' "$jsonConfigFile" > "$tempConfigFile"
return 0
fi

return 1
}

_isConfigServer() {
_mongod_hack_have_arg --configsvr "$@" || {
_parse_config "$@" \
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
&& [ "$clusterRole" = 'configsvr' ]
}
}

dbPath=
_dbPath() {
if [ -n "$dbPath" ]; then
Expand All @@ -226,11 +235,7 @@ _dbPath() {
fi

if [ -z "$dbPath" ]; then
if _mongod_hack_have_arg --configsvr "$@" || {
_parse_config "$@" \
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
&& [ "$clusterRole" = 'configsvr' ]
}; then
if _isConfigServer "$@"; then
# if running as config server, then the default dbpath is /data/configdb
# https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr
dbPath=/data/configdb
Expand Down Expand Up @@ -314,6 +319,12 @@ if [ "$originalArgOne" = 'mongod' ]; then
if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then
_mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}"
fi
# Setting sharding.clusterRole=configsvr requires the mongod instance to be running with replication
# disable configsvr for initial startup (https://github.com/docker-library/mongo/issues/509)
if _isConfigServer "$@"; then
_mongod_hack_ensure_no_arg '--configsvr' "${mongodHackedArgs[@]}"
_mongod_hack_ensure_arg_val '--dbpath' "$dbPath" "${mongodHackedArgs[@]}"
fi

# "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters"
tlsMode='disabled'
Expand Down