Add runner management health check for /ping

Even though we can check the health of the runner management, we would like to ensure an external health check validates the availability of all required services.
This commit is contained in:
Sebastian Serth
2023-03-13 22:54:14 +01:00
parent 0643bc8c0c
commit 0dd931fba1
5 changed files with 42 additions and 1 deletions

View File

@ -153,6 +153,16 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
end
end
def self.health
url = "#{config[:url]}/ping"
response = Faraday.get(url)
JSON.parse(response.body)['message'] == 'Pong'
rescue Faraday::Error => e
raise Runner::Error::FaradayError.new("Request to DockerContainerPool failed: #{e.inspect}")
rescue JSON::ParserError => e
raise Runner::Error::UnexpectedResponse.new("DockerContainerPool returned invalid JSON: #{e.inspect}")
end
def self.release
url = "#{config[:url]}/docker_container_pool/dump_info"
response = Faraday.get(url)