Skip to content

Commit

Permalink
Add checks for querying remote end points in case of network errors.
Browse files Browse the repository at this point in the history
Signed-off-by: Tully Foote <[email protected]>
  • Loading branch information
tfoote committed Sep 26, 2024
1 parent df61dad commit ff37955
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions _plugins/rosindex_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ def update_local(site, repo_instances)
next
end

puts "Updating repo / instance "+repo.name+" / "+repo.id+" from uri: "+repo.uri

# open or initialize this repo
local_path = File.join(@checkout_path, repo_instances.name, id)

puts "Updating repo / instance "+repo.name+" / "+repo.id+" from uri: "+repo.uri+" into path: "+local_path

# make sure there's an actual uri
unless repo.uri
raise IndexException.new("No URI for repo instance " + id, id)
Expand Down Expand Up @@ -229,7 +229,19 @@ def map_build_result_to_icon(build_result)
def get_ci_data(distro, package_name, repo_name)
ci_data = Hash.new
manifest_url = "/#{DEFAULT_LANGUAGE_PREFIX}/#{distro}/api/#{package_name}/manifest.yaml"
manifest_response = Net::HTTP.get_response('docs.ros.org', manifest_url)
begin
manifest_response = Net::HTTP.get_response('docs.ros.org', manifest_url)
rescue StandardError => e
puts " Failed to fetch manifest from #{manifest_url} with error #{e.class}"
ci_data['tooltip'] = 'Error fetching CI information available for this package.'
ci_data['ci_available'] = false
return ci_data
rescue
puts " Failed to fetch manifest from #{manifest_url} with unknown error"
ci_data['tooltip'] = 'Error fetching CI information available for this package.'
ci_data['ci_available'] = false
return ci_data
end
if manifest_response.code != '200'
ci_data['tooltip'] = 'No CI information available for this package.'
ci_data['ci_available'] = false
Expand All @@ -250,7 +262,15 @@ def get_ci_data(distro, package_name, repo_name)
ci_data['job_url'] = manifest_yaml['devel_jobs'][0]
# get additional test information if available
results_url = "/#{DEFAULT_LANGUAGE_PREFIX}/#{distro}/devel_jobs/#{repo_name}/results.yaml"
results_response = Net::HTTP.get_response('docs.ros.org', results_url)
begin
results_response = Net::HTTP.get_response('docs.ros.org', results_url)
rescue
ci_data['tooltip'] = "Latest build information: " + ci_data['timestamp'] + "\n" \
'No test statistics available for this package.'
ci_data['result'] = 'success'
ci_data['stats_available'] = false
return ci_data
end
if results_response.code != '200'
ci_data['tooltip'] = "Latest build information: " + ci_data['timestamp'] + "\n" \
'No test statistics available for this package.'
Expand Down

0 comments on commit ff37955

Please sign in to comment.