-
Notifications
You must be signed in to change notification settings - Fork 224
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
Exit code on db:dump is always 0 #929
Comments
Bug confirmed in v4.9.1 |
Found an issue in result of the piped command. Example:
We have a special pipehandling for bash compatible shells included. |
Tried with Symfony/Process component. Seems that internally any shell_exec or proc_open with piped commands is executed in OS default shell. |
@cmuench Spotted this and wonder if you have come across this before? http://cfajohnson.com/shell/cus-faq-2.html#Q11 Might be useful, may still produce a dump file but allow you to get the exit code somehow |
I am thankful for every hint. |
🙈 Maybe it's a case of doing it in multiple processes / steps? mysqldump --single-transaction --quick -h'db' -u'db' --password='db1' 'db' > db.sql.tmp
# if exit code !=0 delete db.sql.tmp and exit 1
LANG=C LC_CTYPE=C LC_ALL=C sed -i -E 's/DEFINER[ ]*=[ ]*`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' db.sql.tmp
# if exit code !=0 delete db.sql.tmp and exit 1
mv db.sql.tmp db.sql
# exit 0 It's probably more convoluted PHP code though |
I agree. This command btw. needs some refactoring. |
Describe the bug
When running the
db:dump
command and mysqldump fails, magerun will still return with an exit code of 0.Expected behaviour
Non-zero exit code on error
Steps to reproduce the issue
magerun db:dump
mysqldump: Got error: 2005: "Unknown MySQL server host ''bielefeld'' (-2)" when trying to connect
echo $?
Technical details
Possible Fix
In script, I currently work around the issue with
$(magerun db:dump --only-command)
(together withset -e -o pipefail
)Additional context
This is important for scripting, e.g. database backup as part of the deployment pipeline. If a backup fails, the pipeline should not continue.
The text was updated successfully, but these errors were encountered: