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

Manually trigger an election (exploratory, unfinshed feature in development) #6474

Merged
merged 4 commits into from
Apr 24, 2019

Conversation

christophermaier
Copy link
Contributor

To help work around some issues in elections, as well as to help
investigate them further, this commit introduces the beginnings of a
potential feature for allowing operators to manually trigger a service
election.

The current incarnation relies on the HAB_FEAT_TRIGGER_ELECTION
feature flag. A Supervisor operating with this flag enabled will
initiate a new election for a service group if a special sentinel file
for that group is found on disk.

To trigger a new election for the service group foo.default, for
example, create the file

/hab/sup/default/data/trigger_foo.default_election

(That is, a file with the name trigger_${SERVICE_GROUP_NAME}_election.)

This should be done on a Supervisor that is actually running the
foo.default service group.

As the Supervisor's main loop executes, it will respond to the
presence of such a file by initiating a new election. The sentinel
file is also deleted, to prevent endless cycles of elections. If the
file is created in such a way that the Supervisor cannot delete it, no
election is triggered.

To monitor this feature in logs, add
habitat_butterfly::server::election_trigger=trace to your RUST_LOG
environment variable (or use info for less noisy log output).

cc: @irvingpop @dmccown

Signed-off-by: Christopher Maier <cmaier@chef.io>
@chef-expeditor
Copy link
Contributor

Hello christophermaier! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

To help work around some issues in elections, as well as to help
investigate them further, this commit introduces the beginnings of a
potential feature for allowing operators to manually trigger a service
election.

The current incarnation relies on the `HAB_FEAT_TRIGGER_ELECTION`
feature flag. A Supervisor operating with this flag enabled will
initiate a new election for a service group if a special sentinel file
for that group is found on disk.

To trigger a new election for the service group `foo.default`, for
example, create the file

   /hab/sup/default/data/trigger_foo.default_election

(That is, a file with the name `trigger_${SERVICE_GROUP_NAME}_election`.)

This should be done on a Supervisor that is actually running the
`foo.default` service group.

As the Supervisor's main loop executes, it will respond to the
presence of such a file by initiating a new election. The sentinel
file is also deleted, to prevent endless cycles of elections. If the
file is created in such a way that the Supervisor cannot delete it, no
election is triggered.

To monitor this feature in logs, add
`habitat_butterfly::server::election_trigger=trace` to your `RUST_LOG`
environment variable (or use `info` for less noisy log output).

Signed-off-by: Christopher Maier <cmaier@chef.io>
Signed-off-by: Christopher Maier <cmaier@chef.io>
Copy link
Contributor

@raskchanky raskchanky left a comment

Choose a reason for hiding this comment

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

One small comment regarding the nesting level but otherwise looks fine to me

Signed-off-by: Christopher Maier <cmaier@chef.io>
Copy link
Contributor

@mwrock mwrock left a comment

Choose a reason for hiding this comment

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

This looks good to me. I am guessing that if this feature gets baked, we would make the election trigger via the sup cli rather than the existence of a file?

@raskchanky
Copy link
Contributor

@mwrock I think that was the end goal, yeah, with proper channels and such for communicating between pieces. The file thing was just something easy to see if this is actually useful.

@christophermaier
Copy link
Contributor Author

@mwrock @raskchanky Yes, that's exactly the plan.

@christophermaier christophermaier merged commit 6119dab into master Apr 24, 2019
@christophermaier christophermaier deleted the cm/trigger-election branch April 24, 2019 21:19
chef-ci added a commit that referenced this pull request Apr 24, 2019
Obvious fix; these changes are the result of automation not creative thinking.
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.

3 participants