Skip to content

Catch errors when scraping datadir from help output #218

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 2 commits into from
Oct 11, 2016

Conversation

yosifkit
Copy link
Member

Before this change, a user would just get the container exiting and zero output. Now a user will get some friendly output about the command that was run and then the error messages that mysqld emitted.

@yosifkit
Copy link
Member Author

Related to #216 (comment)

@tianon
Copy link
Member

tianon commented Sep 30, 2016

LGTM!

cc @ltangvald

@ltangvald
Copy link
Collaborator

Maybe separate it from the datadir fetch? We have a commit for this in the upstream image, actually:
mysql@05833af

@yosifkit
Copy link
Member Author

yosifkit commented Oct 3, 2016

I'm not sure I understand the need to separate the error detection from the datadir scraping. This code ensures we only have to run mysqld --verbose --help once to get the error and datadir. Plus, now that we have the _datadir function this ensures that the command is checked for errors any time it is called (which is currently two times, once as root, line 27/37, and once as mysql user, line 35/45)

@ltangvald
Copy link
Collaborator

It's somewhat a personal preference since I think it's easier to read and understand the code, but there is some benefit to keeping different logical operations (fetch datadir and check for errors) separate, since it makes future debugging and maintenance simpler.

@yosifkit
Copy link
Member Author

yosifkit commented Oct 4, 2016

That makes sense, though the only problem I have with separating them is that they could become out of sync. The reason for checking for errors is to make sure the datadir scraping will succeed.

As an alternative solution, we could just ignore the failure and add an || true. Aside from the non-zero exit, are there any mysqld --verbose -help errors that would cause the datadir scrape to fail? Perhaps we just allow it to fail later when it does mysql_install_db or --initialize-insecure.

@ltangvald
Copy link
Collaborator

Yeah, we added it as a more general error checking to fail fast and notify users if e.g. a custom config contains invalid entries, not specifically for the datadir scrape. I think it's a useful thing to have, since it lets us print a decent error message in such cases.

Can't really think of anything else that would cause the scrape to fail.

@yosifkit yosifkit force-pushed the fix-datadir-scrape branch from d414024 to a1fce0d Compare October 7, 2016 21:53
@yosifkit
Copy link
Member Author

yosifkit commented Oct 7, 2016

Updated to separate config error check and datadir scraping.

if ! errors="$("${toRun[@]}" 2>&1 >/dev/null)"; then
cat >&2 <<-EOM

ERROR: mysqld failed while attempting to determine datadir
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to update this text to something more appropriate.

@ltangvald
Copy link
Collaborator

LGTM

@tianon
Copy link
Member

tianon commented Oct 11, 2016

👍

@tianon tianon merged commit 0312071 into docker-library:master Oct 11, 2016
@tianon tianon deleted the fix-datadir-scrape branch October 11, 2016 20:18
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