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

before_update hook always runs #632

Closed
waderobson opened this issue Feb 11, 2019 · 4 comments · May be fixed by #661
Closed

before_update hook always runs #632

waderobson opened this issue Feb 11, 2019 · 4 comments · May be fixed by #661
Projects
Milestone

Comments

@waderobson
Copy link

Hi I just ran across some unexpected behavior today.

After I've deploy a stack(create) the before_update hook runs even if there are no updates to perform..
The after_update hook however, only runs if there is updates performed.

Is this intended behavior?

hooks:
  before_update:
    - !cmd "echo heelllooooo"
  after_update:
    - !cmd "echo heelllooooo"
[2019-02-11 15:39:06] - marjory/base - Launching Stack
[2019-02-11 15:39:06] - marjory/base - Stack is in the UPDATE_COMPLETE state
heelllooooo
[2019-02-11 15:39:06] - marjory/base - Updating Stack
[2019-02-11 15:39:09] - marjory/base - No updates to perform.
@zaro0508
Copy link
Contributor

The docs are not real clear but I believe the intended behavior is that hooks should only execute when there are stack updates. I have confirmed that all hooks behave this way except for the before_update hook which seems to run even if there there are no stack updates. I believe this is inconsistent behavior and should be a bug.

@waderobson
Copy link
Author

waderobson commented Feb 12, 2019

That's my take too.
The examples suggest that you can run the provided asg hook before, to suspend and and after, to resume. This will create a problem if you're suspending all the time but only resuming if the stack had an update.

I'll try and dig into this more and see if this is a regresion or not. I've only observed this with versions 2.0.0 and 2.0.1

devenney pushed a commit to devenney/sceptre that referenced this issue Mar 13, 2019
* Create change sets before any update operation to test for changes
* Only execute before_update hook when change set is empty
* Update tests to mock non-empty change sets

Resolves Sceptre#632.

Co-authored-by: Amy Robertson <amylrobertson@icloud.com>
Co-authored-by: Chip Wolf <hello@chipwolf.uk>
Co-authored-by: David Munn <dcwmunn@gmail.com>

Signed-off-by: Brendan Devenney <brendan.devenney@cloudreach.com>
@ngfgrant ngfgrant added this to the 2.1.3 milestone May 9, 2019
@ngfgrant ngfgrant added this to To do in Sceptre May 9, 2019
@cornerman
Copy link
Contributor

cornerman commented Jun 10, 2019

I agree with the proposed solution here, that before_update should only run if there are updates and that it should always have a succeeding after_update.

But can we have another hook that would be run every time a command stack is run like before_run and after_run? I am currently using after_create together with before_update in order to be always run, whenever the respective stack is launched. I need this to sync files into an s3-bucket which is created in this stack and I always want the current files to be there after running launch. Is there a better way?

@ngfgrant
Copy link
Contributor

The intended behaviour is that the hooks are triggered before/after the command is initiated. I think the confusion is maybe related to #678 which will be fixed in 2.1.4 with better error handling which allows program to execute fully.

Sceptre automation moved this from To do to Done Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

4 participants