Adapt dashboard to show idle and used runners

This commit is contained in:
Sebastian Serth
2021-12-06 23:56:31 +01:00
parent a4003ca733
commit 563e14a44a
8 changed files with 68 additions and 27 deletions

View File

@ -166,7 +166,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
url = "#{config[:url]}/docker_container_pool/quantities"
response = Faraday.get(url)
pool_size = JSON.parse(response.body)
pool_size.transform_keys(&:to_i)
pool_size.deep_symbolize_keys
rescue Faraday::Error => e
raise Runner::Error::FaradayError.new("Request to DockerContainerPool failed: #{e.inspect}")
rescue JSON::ParserError => e

View File

@ -176,7 +176,23 @@ class Runner::Strategy::Poseidon < Runner::Strategy
end
def self.pool_size
{}
url = "#{config[:url]}/statistics/execution-environments"
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Getting statistics from #{url}" }
response = http_connection.get url
case response.status
when 200
response_body = parse response
response_body
else
handle_error response
end
rescue Faraday::Error => e
raise Runner::Error::FaradayError.new("Request to Poseidon failed: #{e.inspect}")
rescue JSON::ParserError => e
# Poseidon should not send invalid json
raise Runner::Error::UnexpectedResponse.new("Error parsing response from Poseidon: #{e.message}")
ensure
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Finished getting statistics" }
end
def self.websocket_header