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

[BUG] Failed concurrent creates of ISM policies should return http 409 #260

Closed
phillbaker opened this issue Feb 3, 2022 · 1 comment
Closed
Labels
backport 1.x bug Something isn't working

Comments

@phillbaker
Copy link

phillbaker commented Feb 3, 2022

Describe the bug

When creating multiple policies on a fresh AWS OpenSearch cluster, it's likely to hit the following error:

elastic: Error 400 (Bad Request): index [.opendistro-ism-config/4pNn5XhHT3SwvIerntYi-A] already exists [type=resource_already_exists_exception]

Also see phillbaker/terraform-provider-elasticsearch#226

To Reproduce
Steps to reproduce the behavior: This is easy to do with a terraform provider but could also be scripted.

  1. Spin up a new cluster
  2. create multiple policies in parallel:
curl -X PUT -H 'Content-type: application/json' -d '{"policy":{"default_state":"hot","description":"Rotate index when the size of the index is too big.","ism_template":{"index_patterns":["logs*"],"priority":1000},"states":[{"actions":[{"rollover":{"min_index_age":"7d","min_size":"150gb"}}],"name":"hot","transitions":[{"conditions":{"min_index_age":"14d"},"state_name":"warm"}]},{"actions":[{"retry":{"count":5,"delay":"1h"},"warm_migration":{}}],"name":"warm","transitions":[{"conditions":{"min_index_age":"21d"},"state_name":"delete"}]},{"actions":[{"delete":{}}],"name":"delete"}]}}' localhost:9200/_plugins/_ism/policies/policy_1 & 
curl -X PUT -H 'Content-type: application/json' -d '{"policy":{"default_state":"hot","description":"For logs-rejected index. Smaller size and time to live index","ism_template":{"index_patterns":["logs-rejected*"],"priority":2000},"states":[{"actions":[{"rollover":{"min_index_age":"1d","min_size":"150gb"}}],"name":"hot","transitions":[{"conditions":{"min_index_age":"3d"},"state_name":"delete"}]},{"actions":[{"delete":{}}],"name":"delete"}]}}' localhost:9200/_plugins/_ism/policies/policy_2 & 

Expected behavior
Instead of a http 400, the specific error code http 409 should be returned, indicating a cluster concurrency issue instead of a request format issue.

Plugins
N/a

Screenshots
N/a

Desktop (please complete the following information):
N/A

Additional context
I believe this code could catch a import org.opensearch.ResourceAlreadyExistsException exception and return the specific error code:

ismIndices.checkAndUpdateIMConfigIndex(object : ActionListener<AcknowledgedResponse> {
override fun onResponse(response: AcknowledgedResponse) {
onCreateMappingsResponse(response)
}
override fun onFailure(t: Exception) {
actionListener.onFailure(ExceptionsHelper.unwrapCause(t) as Exception)
}

Similar to opensearch-project/security#1402 and opensearch-project/security#1095

@khushbr
Copy link
Contributor

khushbr commented Aug 3, 2022

I will start looking into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.x bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants