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

Adding ml_settings entry to HLRC and Docs for deprecation_info #38118

Merged
Show file tree
Hide file tree
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 @@ -37,16 +37,19 @@ public class DeprecationInfoResponse {
private static final ParseField CLUSTER_SETTINGS = new ParseField("cluster_settings");
private static final ParseField NODE_SETTINGS = new ParseField("node_settings");
private static final ParseField INDEX_SETTINGS = new ParseField("index_settings");
private static final ParseField ML_SETTINGS = new ParseField("ml_settings");

private final List<DeprecationIssue> clusterSettingsIssues;
private final List<DeprecationIssue> nodeSettingsIssues;
private final Map<String, List<DeprecationIssue>> indexSettingsIssues;
private final List<DeprecationIssue> mlSettingsIssues;

public DeprecationInfoResponse(List<DeprecationIssue> clusterSettingsIssues, List<DeprecationIssue> nodeSettingsIssues,
Map<String, List<DeprecationIssue>> indexSettingsIssues) {
Map<String, List<DeprecationIssue>> indexSettingsIssues, List<DeprecationIssue> mlSettingsIssues) {
this.clusterSettingsIssues = Objects.requireNonNull(clusterSettingsIssues, "cluster settings issues cannot be null");
this.nodeSettingsIssues = Objects.requireNonNull(nodeSettingsIssues, "node settings issues cannot be null");
this.indexSettingsIssues = Objects.requireNonNull(indexSettingsIssues, "index settings issues cannot be null");
this.mlSettingsIssues = Objects.requireNonNull(mlSettingsIssues, "ml settings issues cannot be null");
}

public List<DeprecationIssue> getClusterSettingsIssues() {
Expand All @@ -61,6 +64,10 @@ public Map<String, List<DeprecationIssue>> getIndexSettingsIssues() {
return indexSettingsIssues;
}

public List<DeprecationIssue> getMlSettingsIssues() {
return mlSettingsIssues;
}

private static List<DeprecationIssue> parseDeprecationIssues(XContentParser parser) throws IOException {
List<DeprecationIssue> issues = new ArrayList<>();
XContentParser.Token token = null;
Expand All @@ -76,6 +83,7 @@ public static DeprecationInfoResponse fromXContent(XContentParser parser) throws
Map<String, List<DeprecationIssue>> indexSettings = new HashMap<>();
List<DeprecationIssue> clusterSettings = new ArrayList<>();
List<DeprecationIssue> nodeSettings = new ArrayList<>();
List<DeprecationIssue> mlSettings = new ArrayList<>();
String fieldName = null;
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
Expand All @@ -85,6 +93,8 @@ public static DeprecationInfoResponse fromXContent(XContentParser parser) throws
clusterSettings.addAll(parseDeprecationIssues(parser));
} else if (NODE_SETTINGS.getPreferredName().equals(fieldName)) {
nodeSettings.addAll(parseDeprecationIssues(parser));
} else if (ML_SETTINGS.getPreferredName().equals(fieldName)) {
mlSettings.addAll(parseDeprecationIssues(parser));
} else if (INDEX_SETTINGS.getPreferredName().equals(fieldName)) {
// parse out the key/value pairs
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
Expand All @@ -96,7 +106,7 @@ public static DeprecationInfoResponse fromXContent(XContentParser parser) throws
}
}
}
return new DeprecationInfoResponse(clusterSettings, nodeSettings, indexSettings);
return new DeprecationInfoResponse(clusterSettings, nodeSettings, indexSettings, mlSettings);
}

@Override
Expand All @@ -106,17 +116,19 @@ public boolean equals(Object o) {
DeprecationInfoResponse that = (DeprecationInfoResponse) o;
return Objects.equals(clusterSettingsIssues, that.clusterSettingsIssues) &&
Objects.equals(nodeSettingsIssues, that.nodeSettingsIssues) &&
Objects.equals(mlSettingsIssues, that.mlSettingsIssues) &&
Objects.equals(indexSettingsIssues, that.indexSettingsIssues);
}

@Override
public int hashCode() {
return Objects.hash(clusterSettingsIssues, nodeSettingsIssues, indexSettingsIssues);
return Objects.hash(clusterSettingsIssues, nodeSettingsIssues, indexSettingsIssues, mlSettingsIssues);
}

@Override
public String toString() {
return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString();
return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString() +
":" + mlSettingsIssues.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void testGetDeprecationInfo() throws IOException {
assertThat(response.getClusterSettingsIssues().size(), equalTo(0));
assertThat(response.getIndexSettingsIssues().size(), equalTo(0));
assertThat(response.getNodeSettingsIssues().size(), equalTo(0));
assertThat(response.getMlSettingsIssues().size(), equalTo(0));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public void testGetDeprecationInfo() throws IOException, InterruptedException {
deprecationInfoResponse.getNodeSettingsIssues(); // <2>
Map<String, List<DeprecationInfoResponse.DeprecationIssue>> indexIssues =
deprecationInfoResponse.getIndexSettingsIssues(); // <3>
List<DeprecationInfoResponse.DeprecationIssue> mlIssues =
deprecationInfoResponse.getMlSettingsIssues(); // <4>
// end::get-deprecation-info-response

// tag::get-deprecation-info-execute-listener
Expand All @@ -195,6 +197,8 @@ public void onResponse(DeprecationInfoResponse deprecationInfoResponse1) { // <1
deprecationInfoResponse.getNodeSettingsIssues();
Map<String, List<DeprecationInfoResponse.DeprecationIssue>> indexIssues =
deprecationInfoResponse.getIndexSettingsIssues();
List<DeprecationInfoResponse.DeprecationIssue> mlIssues =
deprecationInfoResponse.getMlSettingsIssues();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ private void toXContent(DeprecationInfoResponse response, XContentBuilder builde
}
}
builder.endObject();

builder.startArray("ml_settings");
for (DeprecationInfoResponse.DeprecationIssue issue : response.getMlSettingsIssues()) {
toXContent(issue, builder);
}
builder.endArray();
}
builder.endObject();
}
Expand Down Expand Up @@ -105,12 +111,14 @@ private List<DeprecationInfoResponse.DeprecationIssue> createRandomIssues(boolea
}

private DeprecationInfoResponse createInstance() {
return new DeprecationInfoResponse(createRandomIssues(true), createRandomIssues(true), createIndexSettingsIssues());
return new DeprecationInfoResponse(createRandomIssues(true), createRandomIssues(true), createIndexSettingsIssues(),
createRandomIssues(true));
}

private DeprecationInfoResponse copyInstance(DeprecationInfoResponse req) {
return new DeprecationInfoResponse(new ArrayList<>(req.getClusterSettingsIssues()),
new ArrayList<>(req.getNodeSettingsIssues()), new HashMap<>(req.getIndexSettingsIssues()));
new ArrayList<>(req.getNodeSettingsIssues()), new HashMap<>(req.getIndexSettingsIssues()),
new ArrayList<>(req.getMlSettingsIssues()));
}

private DeprecationInfoResponse mutateInstance(DeprecationInfoResponse req) {
Expand All @@ -128,16 +136,21 @@ public void testFromXContent() throws IOException {
}

public void testNullFailedIndices() {
NullPointerException exception =
expectThrows(NullPointerException.class, () -> new DeprecationInfoResponse(null, null, null));
NullPointerException exception = expectThrows(NullPointerException.class,
() -> new DeprecationInfoResponse(null, null, null, null));
assertEquals("cluster settings issues cannot be null", exception.getMessage());

exception = expectThrows(NullPointerException.class, () -> new DeprecationInfoResponse(Collections.emptyList(), null, null));
exception = expectThrows(NullPointerException.class,
() -> new DeprecationInfoResponse(Collections.emptyList(), null, null, null));
assertEquals("node settings issues cannot be null", exception.getMessage());

exception = expectThrows(NullPointerException.class,
() -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), null));
() -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), null, null));
assertEquals("index settings issues cannot be null", exception.getMessage());

exception = expectThrows(NullPointerException.class,
() -> new DeprecationInfoResponse(Collections.emptyList(), Collections.emptyList(), Collections.emptyMap(), null));
assertEquals("ml settings issues cannot be null", exception.getMessage());
}

public void testEqualsAndHashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ include-tagged::{doc-tests-file}[{api}-response]
<1> a List of Cluster deprecations
<2> a List of Node deprecations
<3> a Map of key IndexName, value List of deprecations for the index
<4> a list of Machine Learning related deprecations
6 changes: 4 additions & 2 deletions docs/reference/migration/apis/deprecation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Example response:
"details" : "This index is named [logs:apache], which contains the illegal character ':'."
}
]
}
},
"ml_settings" : [ ]
}
--------------------------------------------------
// NOTCONSOLE
Expand Down Expand Up @@ -109,7 +110,8 @@ key. Similarly, any node-level warnings are found under `node_settings`. Since
only a select subset of your nodes might incorporate these settings, it is
important to read the `details` section for more information about which nodes
are affected. Index warnings are sectioned off per index and can be filtered
using an index-pattern in the query.
using an index-pattern in the query. Machine Learning related deprecation
warnings can be found under the `ml_settings` key.

The following example request shows only index-level deprecations of all
`logstash-*` indices:
Expand Down