You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by ea...@apache.org on 2020/08/04 22:49:19 UTC
[incubator-sdap-ingester] 04/11: the healthchecks now raise
exceptions if they rail
This is an automated email from the ASF dual-hosted git repository.
eamonford pushed a commit to branch rabbitmq-fix
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git
commit 1be91cdca001fc15639bb175efdbdb1115e15dca
Author: Eamon Ford <ea...@jpl.nasa.gov>
AuthorDate: Fri Jul 10 10:14:05 2020 -0500
the healthchecks now raise exceptions if they rail
---
granule_ingester/granule_ingester/consumer/Consumer.py | 12 ++++++------
granule_ingester/granule_ingester/main.py | 1 +
granule_ingester/granule_ingester/writers/DataStore.py | 1 +
granule_ingester/granule_ingester/writers/SolrStore.py | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/granule_ingester/granule_ingester/consumer/Consumer.py b/granule_ingester/granule_ingester/consumer/Consumer.py
index 439415f..59db4e8 100644
--- a/granule_ingester/granule_ingester/consumer/Consumer.py
+++ b/granule_ingester/granule_ingester/consumer/Consumer.py
@@ -16,8 +16,9 @@
import logging
import aio_pika
-import sys
-from granule_ingester.exceptions import PipelineBuildingError, PipelineRunningError, ConnectionErrorRabbitMQ
+
+from granule_ingester.exceptions import PipelineBuildingError, PipelineRunningError, RabbitMQConnectionError, \
+ RabbitMQFailedHealthCheckError
from granule_ingester.healthcheck import HealthCheck
from granule_ingester.pipeline import Pipeline
@@ -48,8 +49,8 @@ class Consumer(HealthCheck):
await connection.close()
return True
except:
- logger.error("Cannot connect to RabbitMQ! Connection string was {}".format(self._connection_string))
- return False
+ raise RabbitMQFailedHealthCheckError(f"Cannot connect to RabbitMQ! "
+ f"Connection string was {self._connection_string}")
async def _get_connection(self) -> aio_pika.Connection:
return await aio_pika.connect_robust(self._connection_string)
@@ -97,8 +98,7 @@ class Consumer(HealthCheck):
except aio_pika.exceptions.MessageProcessError:
# Do not try to close() the queue iterator! If we get here, that means the RabbitMQ
# connection has died, and attempting to close the queue will only raise another exception.
- raise ConnectionErrorRabbitMQ("Lost connection to RabbitMQ while processing a granule.")
+ raise RabbitMQConnectionError("Lost connection to RabbitMQ while processing a granule.")
except Exception as e:
queue_iter.close()
raise e
-
diff --git a/granule_ingester/granule_ingester/main.py b/granule_ingester/granule_ingester/main.py
index a7a66c6..86bc569 100644
--- a/granule_ingester/granule_ingester/main.py
+++ b/granule_ingester/granule_ingester/main.py
@@ -15,6 +15,7 @@
import argparse
import asyncio
+from granule_ingester.exceptions import FailedHealthCheckError
import logging
from functools import partial
from typing import List
diff --git a/granule_ingester/granule_ingester/writers/DataStore.py b/granule_ingester/granule_ingester/writers/DataStore.py
index 889d41e..a64399b 100644
--- a/granule_ingester/granule_ingester/writers/DataStore.py
+++ b/granule_ingester/granule_ingester/writers/DataStore.py
@@ -7,6 +7,7 @@ from granule_ingester.healthcheck import HealthCheck
class DataStore(HealthCheck, ABC):
+
@abstractmethod
def save_data(self, nexus_tile: nexusproto.NexusTile) -> None:
pass
diff --git a/granule_ingester/granule_ingester/writers/SolrStore.py b/granule_ingester/granule_ingester/writers/SolrStore.py
index 9d6a7f0..6baad28 100644
--- a/granule_ingester/granule_ingester/writers/SolrStore.py
+++ b/granule_ingester/granule_ingester/writers/SolrStore.py
@@ -26,7 +26,7 @@ from nexusproto.DataTile_pb2 import *
from tenacity import *
from granule_ingester.writers.MetadataStore import MetadataStore
-
+from granule_ingester.exceptions import SolrFailedHealthCheckError
logger = logging.getLogger(__name__)
@@ -56,7 +56,7 @@ class SolrStore(MetadataStore):
else:
logger.error("Solr health check returned status {}.".format(response.status))
except aiohttp.ClientConnectionError as e:
- logger.error("Cannot connect to Solr!")
+ raise SolrFailedHealthCheckError("Cannot connect to to Solr!")
return False