Skip to content

Commit

Permalink
Catch and log errors publishing PD process events
Browse files Browse the repository at this point in the history
OOIION-728
  • Loading branch information
labisso committed Feb 21, 2013
1 parent 1133e0a commit 25cb27b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
10 changes: 7 additions & 3 deletions ion/services/cei/process_dispatcher_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,13 @@ def notify_process(self, process):
return

log.debug("Emitting event for process state. process=%s state=%s", process_id, ion_process_state)
self.event_pub.publish_event(event_type="ProcessLifecycleEvent",
origin=process_id, origin_type="DispatchedProcess",
state=ion_process_state)
try:
self.event_pub.publish_event(event_type="ProcessLifecycleEvent",
origin=process_id, origin_type="DispatchedProcess",
state=ion_process_state)
except Exception:
log.exception("Problem emitting event for process state. process=%s state=%s",
process_id, ion_process_state)


# should be configurable to support multiple process dispatchers?
Expand Down
20 changes: 19 additions & 1 deletion ion/services/cei/test/test_process_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from interface.services.coi.iresource_registry_service import ResourceRegistryServiceClient

from ion.services.cei.process_dispatcher_service import ProcessDispatcherService,\
PDLocalBackend, PDNativeBackend, get_dashi, get_pd_dashi_name, PDDashiHandler
PDLocalBackend, PDNativeBackend, get_dashi, get_pd_dashi_name, PDDashiHandler,\
Notifier
from ion.services.cei.test import ProcessStateWaiter

try:
Expand Down Expand Up @@ -762,6 +763,23 @@ def test_create_invalid_definition(self):
}


@attr('INT', group='cei')
class ProcessDispatcherNotifierTest(IonIntegrationTestCase):

def setUp(self):
self._start_container()

def test_event_publish_unicode_error(self):
process = Mock()
process.process_id = "some_process_id"
process.state = "500-RUNNING"
notifier = Notifier()
notifier.event_pub = Mock()

notifier.event_pub.publish_event.side_effect = Exception()
notifier.notify_process(process)


def _get_eeagent_config(node_id, persistence_dir, slots=100, resource_id=None):

resource_id = resource_id or uuid.uuid4().hex
Expand Down

0 comments on commit 25cb27b

Please sign in to comment.