Catch individual errors instead of failing the entire job for course
indexing.
This commit is contained in:
@@ -101,4 +101,7 @@ class Command(BaseCommand):
|
||||
course_keys = list(map(self._parse_course_key, course_ids))
|
||||
|
||||
for course_key in course_keys:
|
||||
CoursewareSearchIndexer.do_course_reindex(store, course_key)
|
||||
try:
|
||||
CoursewareSearchIndexer.do_course_reindex(store, course_key)
|
||||
except Exception as exc:
|
||||
logging.exception('Error indexing course %s due to the error: %s', course_key, exc)
|
||||
|
||||
@@ -119,11 +119,3 @@ class TestReindexCourse(ModuleStoreTestCase):
|
||||
|
||||
patched_yes_no.assert_called_once_with(ReindexCommand.CONFIRMATION_PROMPT, default='no')
|
||||
patched_index.assert_not_called()
|
||||
|
||||
def test_fail_fast_if_reindex_fails(self):
|
||||
""" Test that fails on first reindexing exception """
|
||||
with mock.patch(self.REINDEX_PATH_LOCATION) as patched_index:
|
||||
patched_index.side_effect = SearchIndexingError("message", [])
|
||||
|
||||
with self.assertRaises(SearchIndexingError):
|
||||
call_command('reindex_course', text_type(self.second_course.id))
|
||||
|
||||
Reference in New Issue
Block a user