-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fetch client --socket value from config during init #266
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
Hardcoding the socket path for the init run broke initdb.d/ scripts that expected a different location (because 5.5 has a different default or the user changed the config). Added a function for fetching it with mysqld --verbose --help as we do for datadir, and use that for the initialization runs of the server and client.
5.5/docker-entrypoint.sh
Outdated
# For use with the client if user passes the --socket argument | ||
_socket() { | ||
"$@" --verbose --help --log-bin-index="$(mktemp -u)" 2>/dev/null | awk '$1 == "socket" { print $2; exit }' | ||
} |
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.
Do you think there'd be any value in making something like a _get_config
function to normalize these two? I guess _check_config
is pretty similar too.
Something like this is what I was kind of thinking:
_get_config() {
local conf="$1"; shift
"$@" --verbose --help --log-bin-index="$(mktemp -u)" 2>/dev/null | awk '$1 == "'"$conf"'" { print $2; exit }'
}
datadir="$(_get_config 'datadir' "$@")"
socket="$(_get_config 'socket' "$@")"
(will defer to your decision, just wanted to throw the idea out there in case you hadn't considered it 👍)
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.
Yeah, I think that's a good idea, so I'll update the pr with it :)
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.
Looks to be working fine. I'll get the pr update up tomorrow once it's applied and tested for all versions.
During container init, we start both server and client temporarily, for user admin etc. For the server we pass on any command line arguments specified by the user, but for the client we don't. This can cause an issue if the user specifies a different socket path, since the client won't find it, causing init failure. Since the socket location doesn't really matter for these temporary runs, we hardcode it to /var/run/mysqld/mysqld.sock
The new function takes as input the config value to fetch
Cool 👍 |
- `docker`: 17.03.1-ce - `haproxy`: 1.7.4 - `kibana`: 5.3.0 - `logstash`: 5.3.0 - `mongo`: simplify entrypoint for 3.4 (docker-library/mongo#156) - `mysql`: fetch `--socket` during initdb (docker-library/mysql#266) - `percona`: `5.7.17-12-1.jessie`, `5.6.35-81.0-1.jessie`, `5.5.54-rel38.7-1.jessie` - `rabbitmq`: `RABBITMQ_DEFAULT_USER_FILE` & `RABBITMQ_DEFAULT_PASS_FILE` support esp. for Docker secrets (docker-library/rabbitmq#143) - `rocket.chat`: 0.54.2
- `docker`: 17.03.1-ce - `haproxy`: 1.7.4 - `kibana`: 5.3.0 - `logstash`: 5.3.0 - `mongo`: simplify entrypoint for 3.4 (docker-library/mongo#156) - `mysql`: fetch `--socket` during initdb (docker-library/mysql#266) - `percona`: `5.7.17-12-1.jessie`, `5.6.35-81.0-1.jessie`, `5.5.54-rel38.7-1.jessie` - `rabbitmq`: `RABBITMQ_DEFAULT_USER_FILE` & `RABBITMQ_DEFAULT_PASS_FILE` support esp. for Docker secrets (docker-library/rabbitmq#143) - `rocket.chat`: 0.54.2
- `docker`: 17.04.0-ce (docker-library/docker#48) - `mariadb`: resync `mysql` entrypoint (MariaDB/mariadb-docker#102; see also docker-library/mysql#249 and docker-library/mysql#266) - `percona`: `5.7.17-13-1.jessie` - `rabbitmq`: multi-version refactoring (docker-library/rabbitmq#134)
Fetch client --socket value from config instead of hardcoding it
Hardcoding the socket path for the init run broke initdb.d/ scripts that
expected a different location (because 5.5 has a different default or the user
changed the config).
Added a function for fetching it with mysqld --verbose --help as we do for
datadir, and use that for the initialization runs of the server and client.
Should fix issue #247