Catch individual errors instead of failing the entire job for course

indexing.
This commit is contained in:
Diana Huang
2020-11-16 13:17:38 -05:00
parent 08c24ed0bf
commit 65d0c11591
2 changed files with 4 additions and 9 deletions

View File

@@ -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)

View File

@@ -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))