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

Do not add indices to not empty alias #1408

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions plugin/storage/es/esRollover.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ def perform_action(action, client, write_alias, read_alias, index_to_rollover, t

index = index_to_rollover + '-000001'
create_index(client, index)
create_aliases(client, read_alias, index)
create_aliases(client, write_alias, index)
if is_alias_empty(client, read_alias):
create_aliases(client, read_alias, index)
if is_alias_empty(client, write_alias):
create_aliases(client, write_alias, index)
elif action == 'rollover':
cond = ast.literal_eval(os.getenv('CONDITIONS', ROLLBACK_CONDITIONS))
rollover(client, write_alias, read_alias, cond)
Expand Down Expand Up @@ -132,6 +134,18 @@ def create_aliases(client, alias_name, archive_index_name):
alias.do_action()


def is_alias_empty(client, alias_name):
""""
Checks whether alias is empty or not
"""
ilo = curator.IndexList(client)
ilo.filter_by_alias(aliases=alias_name)
if len(ilo.working_list()) > 0:
print("Alias {} is not empty. Not adding indices to it.".format(alias_name))
return False
return True


def rollover(client, write_alias, read_alias, conditions):
"""
Rollover to new index and put it into read alias
Expand Down