Skip to content

Commit

Permalink
Handle network exceptions when accessing egg URL (#3588)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Huth <[email protected]>
(cherry picked from commit 0a0753d)
  • Loading branch information
mhuth authored and xiangce committed Nov 10, 2022
1 parent 932ccd9 commit 6106380
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions insights/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,14 @@ def get_egg_url(self):
url = self.connection.base_url + '/platform' + constants.module_router_path
else:
url = self.connection.base_url + constants.module_router_path
response = self.connection.get(url)
if response.status_code == 200:
return response.json()["url"]
else:
logger.warning("Unable to fetch egg url. Defaulting to /release")
try:
response = self.connection.get(url)
if response.status_code == 200:
return response.json()["url"]
else:
raise ConnectionError("%s: %s" % (response.status_code, response.reason))
except ConnectionError as e:
logger.warning("Unable to fetch egg url %s: %s. Defaulting to /release", url, str(e))
return '/release'

def fetch(self, force=False):
Expand Down

0 comments on commit 6106380

Please sign in to comment.