Skip to content

Commit

Permalink
Do not raise KeyError on Indices.get_indices
Browse files Browse the repository at this point in the history
On an index recently created, index metadata can not be ready in ES (for
example, a logstash index being created by the current stack).
get_indices method should not fail, especially if include_aliases is
False.
  • Loading branch information
afrancais committed Apr 8, 2014
1 parent 7be1c86 commit 1c0dde0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyes/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ def get_indices(self, include_aliases=False):
indices_metadata = state['metadata']['indices']
for index in sorted(indices_status.keys()):
info = indices_status[index]
metadata = indices_metadata[index]
num_docs = info['docs']['num_docs']
result[index] = dict(num_docs=num_docs)
if not include_aliases:
continue
try:
metadata = indices_metadata[index]
except KeyError:
continue
for alias in metadata.get('aliases', []):
try:
alias_obj = result[alias]
Expand Down

0 comments on commit 1c0dde0

Please sign in to comment.