Skip to content

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

Merged
merged 3 commits into from
Mar 24, 2017

Conversation

ltangvald
Copy link
Collaborator

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

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.
# 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 }'
}
Copy link
Member

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 👍)

Copy link
Collaborator Author

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 :)

Copy link
Collaborator Author

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.

ltangvald referenced this pull request in mysql/mysql-docker Feb 28, 2017
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
@yosifkit yosifkit requested a review from tianon March 24, 2017 17:09
@tianon
Copy link
Member

tianon commented Mar 24, 2017

Cool 👍

@tianon tianon merged commit 93e98b9 into docker-library:master Mar 24, 2017
tianon added a commit to infosiftr/stackbrew that referenced this pull request Mar 29, 2017
- `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
tianon added a commit to infosiftr/stackbrew that referenced this pull request Mar 30, 2017
- `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
tianon added a commit to infosiftr/mariadb that referenced this pull request Apr 5, 2017
tianon added a commit to infosiftr/mariadb that referenced this pull request Apr 5, 2017
tianon added a commit to infosiftr/stackbrew that referenced this pull request Apr 6, 2017
- `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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants