Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes on search index command #1245

Merged
merged 1 commit into from Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Expand Up @@ -2,14 +2,14 @@

## Current (in progress)

- Nothing yet
- Fixes on the `search index command` [#1245](https://github.com/opendatateam/udata/pull/1245)

## 1.2.1 (2017-10-26)

- Introduce `udata search index` commmand to replace both deprecated `udata search init` and `udata search reindex` commands. They will be removed in udata 1.4. [#1233](https://github.com/opendatateam/udata/pull/1233)
- Rollback oauthlib from 2.0.5 to 2.0.2, pending a permanent solution [#1237](https://github.com/opendatateam/udata/pull/1237)
- Get cached linkchecker result before hitting API [#1235](https://github.com/opendatateam/udata/pull/1235)
- Cleanup resources checksum [migration] [#1239](https://github.com/opendatateam/udata/pull/1239)
- Cleanup resources checksum (migration) [#1239](https://github.com/opendatateam/udata/pull/1239)
- Show check results in resource modal [#1242](https://github.com/opendatateam/udata/pull/1242)
- Cache avatar rendering [#1243](https://github.com/opendatateam/udata/pull/1243)

Expand Down
17 changes: 11 additions & 6 deletions udata/search/commands.py
Expand Up @@ -120,7 +120,6 @@ def set_alias(index_name, delete=True):
es.indices.delete(index=index)
else:
es.indices.put_alias(index=index_name, name=es.index_name)
es.indices.refresh()


@contextmanager
Expand All @@ -133,17 +132,21 @@ def handle_error(index_name, keep=False):
# Handle keyboard interrupt
signal.signal(signal.SIGINT, signal.default_int_handler)
signal.signal(signal.SIGTERM, signal.default_int_handler)
has_error = False
try:
yield
except KeyboardInterrupt:
print('') # Proper warning message under the "^C" display
log.warning('Interrupted by signal')
has_error = True
except Exception as e:
log.error(e)
if not keep:
log.info('Removing index %s', index_name)
es.indices.delete(index=index_name)
sys.exit(-1)
has_error = True
if has_error:
if not keep:
log.info('Removing index %s', index_name)
es.indices.delete(index=index_name)
sys.exit(-1)


@m.option('-t', '--type', dest='doc_type', required=True,
Expand Down Expand Up @@ -223,5 +226,7 @@ def index(models=None, name=None, force=False, keep=False):
'doc_type': adapter.doc_type()
})

enable_refresh(index_name)
enable_refresh(index_name)
# At this step, we don't want error handler to delete the index
# in case of error
set_alias(index_name, delete=not keep)