-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Support specifying multiple templates names in delete composable index template api #70094
Support specifying multiple templates names in delete composable index template api #70094
Conversation
…x template api. Add support to delete composable index templates api to specify multiple template names separated by a comma. Change to cleanup template logic for rest tests to remove all composable index templates via a single delete composable index template request. This to optimize the cleanup logic. After each rest test we delete all templates. So deleting templates this via a single api call (and thus single cluster state update) saves a lot of time considering the number of rest tests. If this pr is accepted then I will do the same change for the delete component template api. Relates to elastic#69973
Pinging @elastic/es-core-features (Team:Core/Features) |
@@ -641,8 +641,10 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS | |||
static ClusterState innerRemoveIndexTemplateV2(ClusterState currentState, String name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should be a string[], and also the name field on request class. Otherwise the request can't be introspected correctly by security.
@@ -575,18 +575,14 @@ private void wipeCluster() throws Exception { | |||
Request getTemplatesRequest = new Request("GET", "_index_template"); | |||
Map<String, Object> composableIndexTemplates = XContentHelper.convertToMap(JsonXContent.jsonXContent, | |||
EntityUtils.toString(adminClient().performRequest(getTemplatesRequest).getEntity()), false); | |||
List<String> names = ((List<?>) composableIndexTemplates.get("index_templates")).stream() | |||
String names = ((List<?>) composableIndexTemplates.get("index_templates")).stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and obviously bwc logic is needed...
I think we may want to reconsider supporting wildcards if we want to support comma-separated values. We already have strangeness with response codes when you mix concrete names with a At some point it becomes very hard to describe to the user whether we did the thing they asked for when we can't be fine-grained in our response. Because we have some issues with this in other APIs, we originally didn't add this for the composable index templates. |
I'm not a big fan of adding support for comma-separated values too. I just like to remove all templates in a single request (cluster state update) just for reducing the time it takes to run the tests. So currently these delete APIs already support simple wildcards. However the xpack templates we need to exclude have many different names and are not sharing a common prefix (See I'm not sure what is best here. Looks like our testing infrastructure does benefit from being able to remove all templates besides the templates managed by ES. Perhaps if comma-separated values are provided then we should prohibit the use of |
I think we could do:
What do you think? |
👍 that proposal sounds good to me. |
…_templates_comma_seperated
…_templates_comma_seperated
@dakrone Do you want to take another look at this PR? |
@martijnvg yep, I will look at it today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Martijn! I left one really minor comment
this.name = name; | ||
return this; | ||
public Request(String... names) { | ||
this.names = names; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit, can you do something like:
this.names = names; | |
this.names = Objects.requireNonNull(names, "templates to delete must not be null"); |
…_templates_comma_seperated
…x template api Backporting elastic#70094 to 7.12 branch. Add support to delete composable index templates api to specify multiple template names separated by a comma. Change to cleanup template logic for rest tests to remove all composable index templates via a single delete composable index template request. This to optimize the cleanup logic. After each rest test we delete all templates. So deleting templates this via a single api call (and thus single cluster state update) saves a lot of time considering the number of rest tests. Relates to elastic#69973
…x template api (elastic#70094) Add support to delete composable index templates api to specify multiple template names separated by a comma. Change to cleanup template logic for rest tests to remove all composable index templates via a single delete composable index template request. This to optimize the cleanup logic. After each rest test we delete all templates. So deleting templates this via a single api call (and thus single cluster state update) saves a lot of time considering the number of rest tests. If this pr is accepted then I will do the same change for the delete component template api. Relates to elastic#69973
… APIs is not supported. The delete legacy template API doesn't support comma-separated list of names in any version. For versions 7.12 and before, the delete component API and delete composable index template API don't support comma-separated list of names. From 7.13 and later, the delete component API and delete composable index template API do support comma-separated list of names. Relates to elastic#70094 and elastic#70314
… APIs is not supported (#70649) The delete legacy template API doesn't support comma-separated list of names in any version. For versions 7.12 and before, the delete component API and delete composable index template API don't support comma-separated list of names. From 7.13 and later, the delete component API and delete composable index template API do support comma-separated list of names. Relates to #70094 and #70314 Co-authored-by: James Rodewig <[email protected]>
… APIs is not supported (elastic#70649) The delete legacy template API doesn't support comma-separated list of names in any version. For versions 7.12 and before, the delete component API and delete composable index template API don't support comma-separated list of names. From 7.13 and later, the delete component API and delete composable index template API do support comma-separated list of names. Relates to elastic#70094 and elastic#70314 Co-authored-by: James Rodewig <[email protected]>
… APIs is not supported (elastic#70649) The delete legacy template API doesn't support comma-separated list of names in any version. For versions 7.12 and before, the delete component API and delete composable index template API don't support comma-separated list of names. From 7.13 and later, the delete component API and delete composable index template API do support comma-separated list of names. Relates to elastic#70094 and elastic#70314 Co-authored-by: James Rodewig <[email protected]>
… APIs is not supported (#70797) Backporting #70649 to 7.11 branch. The delete legacy template API doesn't support comma-separated list of names in any version. For versions 7.12 and before, the delete component API and delete composable index template API don't support comma-separated list of names. From 7.13 and later, the delete component API and delete composable index template API do support comma-separated list of names. Relates to #70094 and #70314 Co-authored-by: James Rodewig <[email protected]>
… APIs is not supported (#70799) Backporting #70649 to 7.10 branch. The delete legacy template API doesn't support comma-separated list of names in any version. For versions 7.12 and before, the delete component API and delete composable index template API don't support comma-separated list of names. From 7.13 and later, the delete component API and delete composable index template API do support comma-separated list of names. Relates to #70094 and #70314 Co-authored-by: James Rodewig <[email protected]>
Add support to delete composable index templates api to specify multiple template
names separated by a comma.
Change to cleanup template logic for rest tests to remove all composable index templates via a single delete composable index template request. This to optimize the cleanup logic. After each rest test we delete all templates. So deleting templates this via a single api call (and thus single cluster state update) saves a lot of time considering the number of rest tests.
If this pr is accepted then I will do the same change for the delete component template api.
Relates to #69973