Skip to content

Conversation

@yzhoubk
Copy link
Contributor

@yzhoubk yzhoubk commented Jan 15, 2026

Add http head check to geoservers and spatial servers

@yzhoubk yzhoubk requested a review from anarchivist January 15, 2026 00:48
@yzhoubk yzhoubk self-assigned this Jan 15, 2026
Copy link
Member

@anarchivist anarchivist left a 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!

Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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.

Comment on lines +34 to +37
def skip_check
mark_failure
mark_message 'No URL configured; health check was skipped...'
end
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants