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

Made small modifications to ESRestTestCase. #70531

Merged
merged 2 commits into from
Mar 18, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -582,20 +582,23 @@ private void wipeCluster() throws Exception {
.map(ct -> (String) ((Map<?, ?>) ct).get("name"))
.filter(name -> isXPackTemplate(name) == false)
.collect(Collectors.toList());
// Ideally we would want to check the version of the elected master node and
// send the delete request directly to that node.
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_13_0))) {
try {
adminClient().performRequest(new Request("DELETE", "_index_template/" + String.join(",", names)));
} catch (ResponseException e) {
logger.warn(new ParameterizedMessage("unable to remove multiple composable index templates {}", names), e);
}
} else {
for (String name : names) {
if (names.isEmpty() == false) {
// Ideally we would want to check the version of the elected master node and
// send the delete request directly to that node.
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_13_0))) {
try {
adminClient().performRequest(new Request("DELETE", "_index_template/" + name));
adminClient().performRequest(new Request("DELETE", "_index_template/" + String.join(",", names)));
} catch (ResponseException e) {
logger.warn(new ParameterizedMessage("unable to remove composable index template {}", name), e);
logger.warn(
new ParameterizedMessage("unable to remove multiple composable index templates {}", names), e);
}
} else {
for (String name : names) {
try {
adminClient().performRequest(new Request("DELETE", "_index_template/" + name));
} catch (ResponseException e) {
logger.warn(new ParameterizedMessage("unable to remove composable index template {}", name), e);
}
}
}
}
Expand All @@ -611,20 +614,23 @@ private void wipeCluster() throws Exception {
.map(ct -> (String) ((Map<?, ?>) ct).get("name"))
.filter(name -> isXPackTemplate(name) == false)
.collect(Collectors.toList());
// Ideally we would want to check the version of the elected master node and
// send the delete request directly to that node.
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_13_0))) {
try {
adminClient().performRequest(new Request("DELETE", "_component_template/" + String.join(",", names)));
} catch (ResponseException e) {
logger.warn(new ParameterizedMessage("unable to remove multiple component templates {}", names), e);
}
} else {
for (String componentTemplate : names) {
if (names.isEmpty() == false) {
// Ideally we would want to check the version of the elected master node and
// send the delete request directly to that node.
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_13_0))) {
try {
adminClient().performRequest(new Request("DELETE", "_component_template/" + componentTemplate));
adminClient().performRequest(new Request("DELETE", "_component_template/" + String.join(",", names)));
} catch (ResponseException e) {
logger.warn(new ParameterizedMessage("unable to remove component template {}", componentTemplate), e);
logger.warn(new ParameterizedMessage("unable to remove multiple component templates {}", names), e);
}
} else {
for (String componentTemplate : names) {
try {
adminClient().performRequest(new Request("DELETE", "_component_template/" + componentTemplate));
} catch (ResponseException e) {
logger.warn(
new ParameterizedMessage("unable to remove component template {}", componentTemplate), e);
}
}
}
}
Expand Down Expand Up @@ -1391,6 +1397,9 @@ protected static boolean isXPackTemplate(String name) {
if (name.startsWith(".transform-")) {
return true;
}
if (name.startsWith(".deprecation-")) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is for: .deprecation-indexing-mappings, .deprecation-indexing-settings and .deprecation-indexing-template templates.

Copy link
Member Author

Choose a reason for hiding this comment

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

Referencing #66413 here, because all this logic in this class about protecting xpack related templates wouldn't be needed if these component and composable index templates are system owned.

return true;
}
switch (name) {
case ".watches":
case "security_audit_log":
Expand All @@ -1407,7 +1416,6 @@ protected static boolean isXPackTemplate(String name) {
case "synthetics-settings":
case "synthetics-mappings":
case ".snapshot-blob-cache":
case ".deprecation-indexing-template":
case "ilm-history":
case "logstash-index-template":
case "security-index-template":
Expand Down