-
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!
lib/check_server.rb
Outdated
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.
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.
Do not use the full urls here. This allows us to check other Geoserver endpoints without modifying the Docker Swarm stack file. If we don't this is necessary, we can put the 4 full urls.
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 my question is why can't we do something like the following in the OkComputer initializer:
OkComputer::Registry.register 'geoserver-public', GeodataHealthCheck::HttpHeadCheck.new(config.x.servers[:geoserver])
OkComputer::Registry.register 'geoserver-secure', GeodataHealthCheck::HttpHeadCheck.new(config.x.servers[:secure_geoserver])
# et ceteraIt might be possible that we need additional helper methods to build out the URL for the GetCapabilities 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.
oh, you'd like all the registry lines in the same file. I'll update it accordingly. Thanks
lib/check_server.rb
Outdated
| 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.
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.
The method where the registry check line located is called in initializer/okcomputer.rb
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'm talking specifically about invoking the method OkComputer::Registry.register. Why are we invoking this method in this part of the code?
lib/check_server.rb
Outdated
| 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.
lib/http_client.rb
Outdated
|
|
||
| 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.
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.
Originally, I planned to issue a Get request if the initial HEAD request returned a redirect, so I added it here. Since we don't need it, I will change it
lib/http_head_check.rb
Outdated
| 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?
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.
Originally, I thought this would improve the output of the health/check page, but it may not be a good idea here.
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 it's not necessary - the rescue pattern will catch if the url is not set.
lib/http_client.rb
Outdated
| 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.)
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.
If we do not use HTTP GET, I will make it simpler
lib/http_client.rb
Outdated
| 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?
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.
Yes, to inherited from OkComputer::HttpCheck
lib/http_head_check.rb
Outdated
| @@ -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.
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.
It sounds good to inherited from HttpCheck. Thanks
lib/check_server.rb
Outdated
| 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.
I'm talking specifically about invoking the method OkComputer::Registry.register. Why are we invoking this method in this part of the code?
lib/check_server.rb
Outdated
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 my question is why can't we do something like the following in the OkComputer initializer:
OkComputer::Registry.register 'geoserver-public', GeodataHealthCheck::HttpHeadCheck.new(config.x.servers[:geoserver])
OkComputer::Registry.register 'geoserver-secure', GeodataHealthCheck::HttpHeadCheck.new(config.x.servers[:secure_geoserver])
# et ceteraIt might be possible that we need additional helper methods to build out the URL for the GetCapabilities method.
lib/http_head_check.rb
Outdated
| 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.
I think it's not necessary - the rescue pattern will catch if the url is not set.
lib/check_server.rb
Outdated
| end | ||
|
|
||
| def spatial_server(type) | ||
| return wrong_type(type) unless %w[public UCB].include? type |
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.
Can you clarify about why we need separate checks for public and UCB-only datasets on spatial?
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.
Just see this note. The UCB-only is configured to redirect to the CAS authentication, should we just ignore 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.
my primary concern for this healthcheck is whether spatial itself reachable - i'm less ocncered about it implicitly checking CAS.
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.
Ok, the ucb spatial endpoint check is removed.
|
@anarchivist I did the updates accordingly, could you please take a look? Thanks |
Add http head check to geoservers and spatial servers