Skip to content

Commit

Permalink
馃敡(search) add elastic search create index timeout
Browse files Browse the repository at this point in the history
Use a new Django setting that allows to change the timeout of the create
index operation on the elastic search. Closes openfun#1613.
  • Loading branch information
igobranco committed Feb 24, 2022
1 parent 765a86c commit 0308d8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- Update frontend overriding system to allow to override any frontend module.

## Added

- Add elastic search create index timeout. Use a new Django setting that allows to change the
timeout of the create index operation on the elastic search.

## [2.13.0] - 2022-02-18

### Added
Expand Down
3 changes: 2 additions & 1 deletion src/richie/apps/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
default_app_config = "richie.apps.search.apps.SearchConfig"

ES_CLIENT = ElasticsearchClientCompat7to6(
[getattr(settings, "RICHIE_ES_HOST", "elasticsearch")]
[getattr(settings, "RICHIE_ES_HOST", "elasticsearch")],
timeout=getattr(settings, "RICHIE_ES_TIMEOUT", 10),
)

ES_INDICES_CLIENT = ElasticsearchIndicesClientCompat7to6(ES_CLIENT)
4 changes: 3 additions & 1 deletion src/richie/apps/search/index_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def perform_create_index(indexable, logger=None):
# Create the new index
if logger:
logger.info(f'Creating a new Elasticsearch index "{new_index:s}"...')
ES_INDICES_CLIENT.create(index=new_index)
ES_INDICES_CLIENT.create(
index=new_index, timeout=getattr(settings, "RICHIE_ES_CREATE_INDEX_TIMEOUT", 10)
)

# The index needs to be closed before we set an analyzer
ES_INDICES_CLIENT.close(index=new_index)
Expand Down

0 comments on commit 0308d8c

Please sign in to comment.