This is an automated email from the ASF dual-hosted git repository.
kmarlis pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/sdap-nexus.git
The following commit(s) were added to refs/heads/develop by this push:
new 3acec41 SDAP 515 - Improved handling of unreachable remote SDAPs
(#308)
3acec41 is described below
commit 3acec41d2d7d36be5f6bd2a9a196189b3710012c
Author: Kevin <[email protected]>
AuthorDate: Thu May 2 13:28:30 2024 -0700
SDAP 515 - Improved handling of unreachable remote SDAPs (#308)
* Improved error handling to account for any reason a remote is not
reachable
* Further fixes for unreachable remote SDAPs
* Improved logging
---
CHANGELOG.md | 2 ++
analysis/webservice/algorithms/DataSeriesList.py | 6 ++----
analysis/webservice/redirect/RemoteSDAPCache.py | 17 ++++++++++-------
3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ad70cd..1531d34 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,8 @@ and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0
- SDAP-493:
- Removed `resultSizeLimit` from /match_spark endpoint
### Fixed
+- SDAP-515:
+ - Improved error handling with connections to remote SDAP deployments
### Security
## [1.2.0] - 2023-11-22
diff --git a/analysis/webservice/algorithms/DataSeriesList.py
b/analysis/webservice/algorithms/DataSeriesList.py
index e247bb6..31e07e6 100644
--- a/analysis/webservice/algorithms/DataSeriesList.py
+++ b/analysis/webservice/algorithms/DataSeriesList.py
@@ -68,10 +68,8 @@ class DataSeriesListCalcHandlerImpl(NexusCalcHandler):
)
del remote_collection['shortName']
current_collection.update(remote_collection)
-
- except CollectionNotFound as e:
- logger.warning(e)
- finally:
collection_list.append(current_collection)
+ except CollectionNotFound as e:
+ logger.warning(e)
return SimpleResult(collection_list)
diff --git a/analysis/webservice/redirect/RemoteSDAPCache.py
b/analysis/webservice/redirect/RemoteSDAPCache.py
index 3b8c772..86da833 100644
--- a/analysis/webservice/redirect/RemoteSDAPCache.py
+++ b/analysis/webservice/redirect/RemoteSDAPCache.py
@@ -38,7 +38,10 @@ class RemoteSDAPCache:
def _add(self, url, timeout=2, max_age=3600*24):
list_url = f"{url}/list"
try:
- r = requests.get(list_url, timeout=timeout)
+ try:
+ r = requests.get(list_url, timeout=timeout)
+ except Exception as e:
+ raise CollectionNotFound(f'URL {list_url} was not reachable')
if r.status_code == 200:
logger.info("Caching list for sdap %s: %s", list_url, r.text)
self.sdap_lists[url] = RemoteSDAPList(
@@ -47,16 +50,16 @@ class RemoteSDAPCache:
)
else:
raise CollectionNotFound(f"url {list_url} was not reachable,
responded with status {r.status_code}")
- except (requests.exceptions.ConnectTimeout,
requests.exceptions.ReadTimeout) as e:
- raise CollectionNotFound(f"url {list_url} was not reachable in
{timeout} s")
+ except CollectionNotFound as e:
+ logger.warning(e)
def get(self, url, short_name):
stripped_url = url.strip('/')
if stripped_url not in self.sdap_lists or
self.sdap_lists[stripped_url].outdated_at>datetime.now():
self._add(stripped_url)
-
- for collection in self.sdap_lists[stripped_url].list:
- if 'shortName' in collection and collection['shortName'] ==
short_name:
- return collection
+ if stripped_url in self.sdap_lists:
+ for collection in self.sdap_lists[stripped_url].list:
+ if 'shortName' in collection and collection['shortName'] ==
short_name:
+ return collection
raise CollectionNotFound(f"collection {short_name} has not been found
in url {stripped_url}")
\ No newline at end of file