Skip to content
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

Only run post-start hook when the new container is actually created, fixes #1115 #1298

Merged
merged 4 commits into from
Dec 1, 2018

Conversation

rfay
Copy link
Member

@rfay rfay commented Nov 24, 2018

The Problem/Issue/Bug:

People who put post-start hooks in really normally want them to run only when the container is created or recreated. A common example is installing an extra Debian package; it only needs to be done when the container is recreated. A start that doesn't recreate doesn't need to run the hook. OP #1115

How this PR Solves The Problem:

  • Touch /var/tmp/ddev_started.txt on startup; check to see if it's been touched if we're going to do a hook.
  • No action is taken if there are no post-start hooks.

Manual Testing Instructions:

  • Create a post-start hook, maybe "bash -c echo hello there"
  • ddev start. You should see it fire
  • ddev start again, you should not see it fire
  • Change the php type and ddev start, container should be recreated and you should see it fire.

Automated Testing Overview:

  • Added test for this behavior in TestDdevStart
  • Also changed TestDdevStart to only run one CMS, as behavior across all CMSs is the same.

Related Issue Link(s):

OP #1115

Release/Deployment notes:

This does in fact change the behavior of the post-start hook, so needs to be announced. Most people will like it, it's probably more what's expected.

@rfay rfay added this to the v1.5.0 milestone Nov 24, 2018
@rfay rfay self-assigned this Nov 24, 2018
@rfay rfay force-pushed the 20181124_post_start_when_matters branch from c4121ce to d76b7ab Compare November 30, 2018 03:48
@rfay rfay force-pushed the 20181124_post_start_when_matters branch from d76b7ab to b493604 Compare November 30, 2018 12:57
Copy link
Contributor

@andrewfrench andrewfrench left a comment

Choose a reason for hiding this comment

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

Pretty clever signalling technique - looks good to me:

hooks:
  post-start:
    - exec: bash -c 'echo hello there'
$ ddev start
// post-start hook runs

$ ddev start
// post start hook does not run

$ ddev config --php-version 7.3
$ ddev start
// post-start hook runs

$ ddev start
// post-start hook does not run

@rfay rfay merged commit 9794512 into ddev:master Dec 1, 2018
@rfay rfay deleted the 20181124_post_start_when_matters branch December 1, 2018 16:31
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.

None yet

2 participants