ddev: Add config.yaml option to fail an action when hooks fail
Is your feature request related to a problem? Please describe.
hooks:
post-start:
- exec: exit 1
# Private files directory.
- exec: mkdir /var/www/private
# Install profile
- exec: drush site-install server -y --existing-config
# Compile theme
- exec-host: ddev robo theme:compile
# Generate one-time login link
- exec: drush uli
Let’s say we have a failing post-start command in our custom configuration.
Right now there’s no trivial way to know if all the commands succeeded or not, as ddev start
exits with code 0 even if something in the hooks failed.
Describe the solution you’d like
We could stop on the first failure for post-start
and propagate the received exit code for the caller of ddev start
.
Describe alternatives you’ve considered
As it might break existing configs, it could be a config option, like stop_on_hook_failure: true
, with a default value false, it would ensure the backwards compatibility.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- Allow configuration to fail when a hook execution fails, fixes #2536 (#2652) — committed to ddev/ddev by majamee 4 years ago
I mean, in our case we can surely check that CSS file was compiled (which is currently our use case); but I think in general stopping on error can be a good thing.
I think even if the exit codes don’t lead to a “ddev start” failing anymore, it would be more than welcome to have the option to achieve that if a critical hook is failing the ddev start gets interrupted as it was before.
Possible solutions:
It would be highly appreciated to give any lead how to interrupt a “ddev start” on purpose. Thank you very much for your efforts. @rfay Maybe one of the above suggestions is considered feasible? 😃