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

Add http probe for CLI healthcheck/readiness/liveliness #452

Merged
merged 1 commit into from
Nov 10, 2021

Conversation

bensheldon
Copy link
Owner

@bensheldon bensheldon commented Nov 6, 2021

Connects to #403. Adds separate endpoints that are descriptive of GoodJob's state (started/connected) because I do not want to be opinionated about what constitutes an appropriate probe.

This PR uses WEBrick as the http server. Ruby 3.0 removes webrick from the stdlib and thus it has to be included in the gemspec.

@bensheldon bensheldon temporarily deployed to goodjob-probe-server-q0hway0ae November 6, 2021 21:22 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-probe-server-q0hway0ae November 7, 2021 15:52 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-probe-server-q0hway0ae November 9, 2021 14:50 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-probe-server-q0hway0ae November 9, 2021 15:00 Inactive
@bensheldon bensheldon added the enhancement New feature or request label Nov 9, 2021
@bensheldon bensheldon merged commit 0986b6e into main Nov 10, 2021
@bensheldon bensheldon deleted the probe_server branch November 10, 2021 00:59
@@ -54,6 +54,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "fugit", ">= 1.1"
spec.add_dependency "railties", ">= 5.2.0"
spec.add_dependency "thor", ">= 0.14.1"
spec.add_dependency "webrick", ">= 1.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why you went for a very old version rather than a version that contains fixes for vulnerabilities? I assume it's for broad compatibility with all kinds of setups, but since webrick 1.7 supports Ruby 2.3 and above and GoodJob Ruby 2.5 and above, we could set this higher and avoid having people install versions with CVEs?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I didn't put much thought into it, though I'm not quite sure how I came to v1.3 as it looks like that shipped with Ruby 2.4, which GoodJob does not support.

I think of the gemspec as descriptive of compatibility; I think security should be considered at the application that is consuming the gemspec. Trying to balance:

  • if the application is not previously including webrick, that bundler is not defaulting to an insecure version (I don't know how Bundler decides whether to pull the latest version, or just whatever it has lying around locally)
  • if the application is previously including webrick, not forcing the application to update the version of webrick because that might be a blocker for the adopting/updating GoodJob in a controlled environment.

The other thing I did consider, rather than pulling in webrick, was just pasting in one of the many "rack-compatible http server in 30 lines of ruby" and packaging it directly. These health check requests are very, very simple and really only intended to be used internally.

end

def start
@handler = Rack::Handler.get(RACK_SERVER)
Copy link
Contributor

@bouk bouk Nov 15, 2021

Choose a reason for hiding this comment

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

@bensheldon if you use Rack::Handler.default here you don't need the dependency on webrick and the handler can be set with an environment flag—it would be nice if it's user-configurable somehow

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ooh, that's interesting. When trying that change, it defaults to Puma, but Puma intercepts ctrl-c/Interrupt which becomes really problematic :-(

This isn't intended to be anything more than a container healthcheck, which makes me think that I should explore pasting in a "rack-compatible http server in 30 lines of ruby" snippet of code and avoid the dependency altogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, then webrick makes more sense 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants