From a4fbf9f11e0fd1e447b73197405880d3605f2306 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Fri, 27 Sep 2024 10:57:58 -0700 Subject: [PATCH] Add checks for querying remote end points in case of network errors. (#429) Signed-off-by: Tully Foote --- _plugins/rosindex_generator.rb | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/_plugins/rosindex_generator.rb b/_plugins/rosindex_generator.rb index c2f3113..ef1553a 100644 --- a/_plugins/rosindex_generator.rb +++ b/_plugins/rosindex_generator.rb @@ -160,11 +160,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) @@ -230,7 +230,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 @@ -251,7 +263,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.'