-
Notifications
You must be signed in to change notification settings - Fork 0
Ap 547: Add other healthchecks to Geodata #71
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
base: main
Are you sure you want to change the base?
Conversation
anarchivist
left a comment
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 this is a good start but I'd like to see this check be closer in alignment to how OkComputer::Check defines its API. I have some questions about whether some of the classes and methods are necessary. Let me know if you'd like to discuss this further!
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.
Why is this class necessary? I'm not sure why we can't just register checks for four URLs directly in the OkComputer initializer.
| server_name = type == 'public' ? GEOSERVER_NAME : SECURE_GEOSERVER_NAME | ||
| url = host_url(server_name) | ||
| geoserver_url = url && "#{url.chomp('/')}/wms?service=WMS&request=GetCapabilities" | ||
| OkComputer::Registry.register clr_msg(server_name), GeoDataHealthCheck::HttpHeadCheck.new(geoserver_url) |
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.
Adding the checks in the registry should only happen in the initializer.
| msg = "#{type} #{SPATIAL_SERVER_NAME}" | ||
| url = host_url(SPATIAL_SERVER_NAME) | ||
| spatial_url = url && "#{url.chomp('/')}/#{type}/berkeley-status/data.zip" | ||
| OkComputer::Registry.register clr_msg(msg), GeoDataHealthCheck::HttpHeadCheck.new(spatial_url) |
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.
Adding the checks in the registry should only happen in the initializer.
|
|
||
| def build_request(method, uri) | ||
| req_method = method.downcase.to_sym | ||
| raise ConnectionFailed, "Incorrect http request method: #{method}" unless %i[head get].include?(req_method) |
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.
Why is GET an allowed method here? We need a custom module/health check specifically for HEAD requests.
| def skip_check | ||
| mark_failure | ||
| mark_message 'No URL configured; health check was skipped...' | ||
| 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.
Why is this method necessary? Shouldn't the rescue on line 27 catch this if url is not defined?
| require 'openssl' | ||
|
|
||
| module GeoDataHealthCheck | ||
| class HttpClient |
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.
Does this need to be its own class? (See related comment below about method naming/location.)
| ConnectionFailed = Class.new(StandardError) | ||
|
|
||
| class << self | ||
| def request(method, url, timeout: 5) |
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.
What would you think about renaming this method to be perform_request and moving it into HttpHeadCheck to follow the same pattern that OkComputer::HttpCheck uses?
| @@ -0,0 +1,39 @@ | |||
| module GeoDataHealthCheck | |||
| class HttpHeadCheck < OkComputer::Check | |||
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.
Is there any advantage to inheriting from OkComputer::HttpCheck instead? You'd then have access to OkComputer::HttpCheck::ConnectionFailed and perhaps could simplify the logic in your #check method below.
Add http head check to geoservers and spatial servers