Raise original exception

Raise orginal exception from LogPublisher if
proceeding or sending message to kafka fails.

Change-Id: I59c4d2fda5bae22b644236673627c18d373d73ac
This commit is contained in:
Artur Basiak 2016-05-19 13:20:21 +02:00
parent 2c42e57554
commit 52e66aa17a
2 changed files with 8 additions and 3 deletions

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import falcon
import itertools
from monasca_common.kafka import producer
@ -182,7 +183,12 @@ class LogPublisher(object):
if not bucket:
LOG.warn('Empty bucket spotted, continue...')
continue
self._kafka_publisher.publish(topic, bucket, key)
try:
self._kafka_publisher.publish(topic, bucket, key)
except Exception as ex:
raise falcon.HTTPServiceUnavailable('Service unavailable',
ex.message, 60)
LOG.debug('Sent %d messages (topics=%s,key=%s)',
len(bucket), topic, key)

View File

@ -131,5 +131,4 @@ class Logs(logs_api.LogsApi):
self._log_publisher.send_message(logs)
except Exception as ex:
LOG.exception(ex)
raise falcon.HTTPServiceUnavailable('Service unavailable',
ex.message, 60)
raise ex