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

Fixed lambda_function to prevent errors during simultaneous deployments #48

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@ def do_indexing(os_client, user_params):
request_timeout=20)
print("Existing alias - Bulk response: ", bulk_response)
print(SECTION_SEPARATOR)


indices_to_remove = [index for index in os_client.indices.get_alias(name=INDEX_ALIAS)]
saimedhi marked this conversation as resolved.
Show resolved Hide resolved

actions=[{"remove": {"index": index, "alias": INDEX_ALIAS}} for index in indices_to_remove]
actions.append({"add": {"index": new_index, "alias": INDEX_ALIAS}})

alias_status = os_client.indices.update_aliases(
{
"actions": [
{"remove": {"index": old_index, "alias": INDEX_ALIAS}},
Copy link
Author

@saimedhi saimedhi Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, we tried to remove old index. This will cause issues with parallel deployments. When we try to remove old index, it may have already been deleted by another parallel thread. So, here ideal solution will be to remove all the indices that are present and add new index. By this we can always have number of indices for a index alias as one or zero(at initial state).

{"add": {"index": new_index, "alias": INDEX_ALIAS}}
]
"actions": actions
}
)
print("Alias update status: ", bulk_response)
Expand Down