buildkite / lifecycled

A daemon for responding to AWS AutoScaling Lifecycle Hooks
MIT License
146 stars 34 forks source link

Add happy path for shutting down the daemon #45

Closed itsdalmo closed 6 years ago

itsdalmo commented 6 years ago

This PR (work in progress) implements the changes proposed in #42.

Things remaining to be done/solved:

Have a look and let me know what you think @lox 👐

itsdalmo commented 6 years ago

If we managed to merge together the best parts of this PR and your #44, I think it would be best to implement any logging changes on top of that. Also, I think your monitor structs would make it easier to follow the code in daemon.Start() of this branch.

itsdalmo commented 6 years ago

@lox - Still a work in progress, but I've added a Listener (much like your Monitors) and Handler interface, as well as Notice interface which gives a lot of flexibility but also makes the flow of the program a lot easier to reason about (in my opinion).

Some outstanding work:

And in the end, we should be able to add some basic unit tests and integration tests. Unit tests will hopefully be easier to add since we are using interfaces, so we can basically fully mock listeners, notices and handlers.

Take a look and let me know what you think!

lox commented 6 years ago

This is looking really good. I'm going to close #44 and we will focus on this one. Some comments:

Aside from that, I'll make some comments as you go!

lox commented 6 years ago

Also made you a contributor, thanks for all your contributions so far 🙇🏼‍♂️

itsdalmo commented 6 years ago

Tested the latest commit on this PR and everything seems to work fine/as expected. Going to clean up log messages now and then ask that you review, and then I think we should make issues of the "outstanding work" we can think of, that are not critical to the refactoring but should be done at some point.

PS: I think it would be nice to use the "squash and merge" button in github to merge this, so that we get 1 commit in master branch, but we can still look at the PR to see all the commits that were squashed?

itsdalmo commented 6 years ago

@lox - I've removed the WIP tag and think this is pretty much ready to merge if you are happy with it also (after you have had a chance to review and test it). Have tested it myself and everything seems to be working as intended; I have not tested actual spot terminations however.

As mentioned above, I think it should be merged with a "squash and merge", but if you rather want me to squash the commits in the PR itself, just let me know (in that case we should probably rename the branch as well).

edit: I just stuck with --spot as the flag for the spot listener. Let me know if you want it changed.

lox commented 6 years ago

I'll do a proper review of this next week and we can look at merging it for a 3.0.0 release?

itsdalmo commented 6 years ago

Sounds good @lox! I've started a new branch (based on this one) to add some testing facilities and basic tests: https://github.com/itsdalmo/lifecycled/tree/add-basic-tests. Thinking that should perhaps also be a part of a 3.0.0 release (can always rewrite the tests later etc, but it's nice to have something)?

lox commented 6 years ago

Merge at your leisure @itsdalmo and then we can look at the tests.

itsdalmo commented 6 years ago

@lox - I'll merge this now, but I think we should wait with 3.0 until we have some tests in place (which might require a little more refactoring to get right).