-
Notifications
You must be signed in to change notification settings - Fork 96
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
Event based Kubernetes liveness probe #319
Conversation
40be758
to
ba06e60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Couple of comments.
I think it would be best to use the existing Config system for this rather than introduce new ENV vars.
Also... should liveness_probe
either 1) be a separate thing in exe/
, e.g. racecar-liveness-probe
or 2) be a new subcommand in racecarctl
?
bin/liveness_probe
Outdated
#!/usr/bin/env -S ruby --disable=gems | ||
|
||
$file_path = ENV.fetch("RACECAR_LIVENESS_PROBE_FILE_PATH", "") | ||
$liveness_max_interval = Integer(ENV.fetch("RACECAR_LIVENESS_PROBE_MAX_INTERVAL")) rescue nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the config system here? Add the vars to Racecar::Config
, e.g. liveness_probe_file_path
? Then folks can pass the value as ENV vars or just configure with YAML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion about that, my thinking here was that I was competing with a bash script.
Something that executes quickly with no dependencies is more palatable to ops people and they will likely want to put those values in the ENV
anyway.
If you don't buy that argument then I'm happy to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also be concerned that people would assume their Rails app is being loaded for the probe, that wouldn't make sense to do that but someone will think that.
I will of course add docs and we can try to make that clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should target the dev ops folks, basically the engineers who write the consumers, and they'd be surprised by having a separate config system. Many people like having their config in a single YAML file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had some discussions around the this when mobbing on #308. With the bash version in that PR, reusing the config was not easy. I agree with @dasch about using the same config although it comes with additional load. cc @jbdietrich
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I would tend to agree that it is better to make this consistent with the existing config API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree; let's use Racecar::Config
for this configuration - besides making it easier to configure, it also helps us maintain documentation on Racecar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback.
It's now executed via racecarctl liveness_probe
, it uses Racecar::Config
and loads config/racecar.yml
if RAILS_ENV
is set in the environment.
Looking for RAILS_ENV
seems to be the best way to check. I expect this to be set in a Kubernetes deployment and we can't load Rails to get the value.
You should be able to extend https://github.com/zendesk/racecar/blob/master/lib/racecar/ctl.rb with a new subcommand. Perhaps pull the probe logic into a new class, e.g. |
Definitely a neater solution but let me know what you think about the "easier for ops people" argument. |
1b47fc7
to
6534537
Compare
@leonmaia would you also like to review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually wanted to rewrite the bash part in #308 into ruby as well, so thanks for this PR! :)
eb3c930
to
878a854
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wohoo!
63a85df
to
c452171
Compare
- Probe command executed via `$ racecarctl liveness_probe` - Liveness probe behavior is disabled by default, set `liveness_probe_enabled` to enable - Triggered by instrumentation events to keep overhead and coupling low
c452171
to
c7f88f9
Compare
Alrighty! Let's add an entry to the CHANGELOG and I can merge this! |
Co-authored-by: Daniel Schierbeck <[email protected]>
c7f88f9
to
ea9b1c4
Compare
This PR is functionally similar to @jbdietrich's PR #308
The main loop of the runner touches a file and a script will exit 0 or 1 depending on whether it was touched recently enough.
Why this implementation?
This has been back-ported into Voice and will be deployed shortly. In testing it has achieved very smooth rolling deploys with minimal disruption to message processing.
After production deployment I'd be happy to update the k8s deployment section of the README.