Skip to content

Commit d76c1d5

Browse files
committed
Fix #8 and #118. Requires umapi-client v2.2.
* look for batch errors from the umapi-client, and mark the corresponding actions as processed. * use the target and command data from the umapi-client to log action details together with error messages about execution.
1 parent 354f7e7 commit d76c1d5

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'pycrypto',
4444
'python-ldap==2.4.25',
4545
'PyYAML',
46-
'umapi-client>=2.1',
46+
'umapi-client>=2.2',
4747
'psutil',
4848
],
4949
setup_requires=['nose>=1.0'],

user_sync/connector/dashboard.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,14 @@ def _execute_action(self, action):
289289
'''
290290
:type action: umapi_client.UserAction
291291
'''
292-
_, sent, _ = self.connection.execute_single(action)
293-
self.process_sent_items(sent)
292+
sent = 0
293+
try:
294+
_, sent, _ = self.connection.execute_single(action)
295+
except umapi_client.BatchError as e:
296+
self.logger.log(logging.CRITICAL, "Unexpected response! Actions may have failed: %s", e)
297+
sent = e.statistics[1]
298+
finally:
299+
self.process_sent_items(sent)
294300

295301
def process_sent_items(self, total_sent):
296302
if (total_sent > 0):
@@ -303,7 +309,10 @@ def process_sent_items(self, total_sent):
303309

304310
if (not is_success):
305311
for error in action_errors:
306-
self.logger.error('Error requestID: %s code: "%s" message: "%s"', action.frame.get("requestID"), error.get('errorCode'), error.get('message'));
312+
self.logger.error('Error in requestID: %s (User: %s, Command: %s): code: "%s" message: "%s"',
313+
action.frame.get("requestID"),
314+
error.get("target", "<Unknown>"), error.get("command", "<Unknown>"),
315+
error.get('errorCode', "<None>"), error.get('message', "<None>"))
307316

308317
item_callback = sent_item['callback']
309318
if (callable(item_callback)):
@@ -314,7 +323,11 @@ def process_sent_items(self, total_sent):
314323
})
315324

316325
def flush(self):
317-
_, sent, _ = self.connection.execute_queued()
318-
self.process_sent_items(sent)
319-
320-
326+
sent = 0
327+
try:
328+
_, sent, _ = self.connection.execute_queued()
329+
except umapi_client.BatchError as e:
330+
self.logger.log(logging.CRITICAL, "Unexpected response! Actions may have failed: %s", e)
331+
sent = e.statistics[1]
332+
finally:
333+
self.process_sent_items(sent)

0 commit comments

Comments
 (0)