-
Notifications
You must be signed in to change notification settings - Fork 0
Adds healthchecks using the OKComputer gem #68
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # initializers/okcomputer.rb | ||
| # Health checks configuration | ||
|
|
||
| OkComputer.logger = Rails.logger | ||
| OkComputer.check_in_parallel = true | ||
|
|
||
| # Check that DB migrations have run | ||
| OkComputer::Registry.register 'database-migrations', OkComputer::ActiveRecordMigrationsCheck.new | ||
|
|
||
| # Check the Solr connection | ||
| # Requires the ping handler on the solr core (<core>/admin/ping). | ||
| core_baseurl = Blacklight.default_index.connection.uri.to_s.chomp('/') | ||
| OkComputer::Registry.register 'solr', OkComputer::SolrCheck.new(core_baseurl) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require 'okcomputer' | ||
|
|
||
| Rails.application.routes.draw do | ||
| mount Blacklight::Engine => '/' | ||
| root to: 'catalog#index' | ||
|
|
@@ -40,4 +42,7 @@ | |
| concerns :gbl_downloadable | ||
| end | ||
| resources :download, only: [:show] | ||
|
|
||
| # Map OkComputer's /health/all.json to /health | ||
| get '/health', to: 'ok_computer/ok_computer#index', defaults: { format: :json } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @awilfox @anarchivist So here's an alternative — we mount OKComputer with its default setting (all routes under /okcomputer) but map
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,7 +182,7 @@ | |
| the PingRequestHandler. | ||
| relative paths are resolved against the data dir | ||
| --> | ||
| <str name="healthcheckFile">server-enabled.txt</str> | ||
| <!-- <str name="healthcheckFile">server-enabled.txt</str> --> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to remain commented or should it be removed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see arguments for both, but I went with this because it minimizes the diff with the solrconfig.xml that ships with GeoBlacklight. If we deleted it, we'd also want to delete the preceding lines/comments.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you explain more about why are we changing this? more context: https://solr.apache.org/docs/8_0_0/solr-core/org/apache/solr/handler/PingRequestHandler.html
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That config requires the named file to exist in the data directory. If it's not there, then even though /admin/ping is configured it returns a 503. I figured this was the easiest way to get it working, the alternative being scaffolding that file into each core's datadir. Note that Solr is firewall'd in staging / prod, so we're not opening things up any more than they currently are.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 ; i think this is fine to go, then. |
||
| </requestHandler> | ||
|
|
||
| <requestHandler name="/analysis/field" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe 'OKComputer', type: :request do | ||
| it 'is mounted at /okcomputer' do | ||
| get '/okcomputer' | ||
| expect(response).to have_http_status :ok | ||
| end | ||
|
|
||
| it 'returns all checks at /health' do | ||
| get '/health' | ||
| expect(response).to have_http_status :ok | ||
| expect(response.parsed_body.keys).to match_array %w[ | ||
| default | ||
| database | ||
| database-migrations | ||
| solr | ||
| ] | ||
| end | ||
| end |
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.
meta question: do we care about doing healthchecks for geoserver and spatial within geodata?
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.
Good suggestion! Yes, both are critical to GeoData's functionality and the checks should be pretty easy to write. I'll see what I can do.
Uh oh!
There was an error while loading. Please reload this page.
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.
@anarchivist I worked through this a bit last night, and I think these checks are a big enough lift to warrant a separate PR. The crux is that unlike with the Solr URL, there's no easy way to get at the GeoServer and Spatial URLs worth monitoring. That data is in Solr, so either we query it at startup or check-time, or we inject it (e.g.
ENV['CHECKS_GEOSERVER_URL']and some conditional logic).So there's quite a bit more decision-making there. I think we should get this basic configuration out now, then address GeoServer/Spatial in a follow-up PR.
What do you think?
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.
👍