Skip to content

Commit

Permalink
Deprecation check for audit log prefix settings (#36661)
Browse files Browse the repository at this point in the history
Adds a deprecation check for removed
`xpack.security.audit.logfile.prefix.` settings
  • Loading branch information
gwbrown committed Dec 17, 2018
1 parent 33dfce0 commit 7dbc28f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private DeprecationChecks() {
static List<BiFunction<List<NodeInfo>, List<NodeStats>, DeprecationIssue>> NODE_SETTINGS_CHECKS =
Collections.unmodifiableList(Arrays.asList(
NodeDeprecationChecks::httpEnabledSettingRemoved,
NodeDeprecationChecks::auditLogPrefixSettingsCheck,
NodeDeprecationChecks::indexThreadPoolCheck,
NodeDeprecationChecks::tribeNodeCheck,
NodeDeprecationChecks::httpPipeliningCheck,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ static DeprecationIssue httpEnabledSettingRemoved(List<NodeInfo> nodeInfos, List
return null;
}

static DeprecationIssue auditLogPrefixSettingsCheck(List<NodeInfo> nodeInfos, List<NodeStats> nodeStats) {
List<String> nodesFound = nodeInfos.stream()
.filter(nodeInfo -> nodeInfo.getSettings().getByPrefix("xpack.security.audit.logfile.prefix").isEmpty() == false)
.map(nodeInfo -> nodeInfo.getNode().getName())
.collect(Collectors.toList());
if (nodesFound.size() > 0) {
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Audit log node info settings renamed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_70_cluster_changes.html" +
"#audit-logfile-local-node-info",
"nodes with audit log settings that have been renamed: " + nodesFound);
}
return null;
}

static DeprecationIssue indexThreadPoolCheck(List<NodeInfo> nodeInfos, List<NodeStats> nodeStats) {
List<String> nodesFound = nodeInfos.stream()
.filter(nodeInfo -> nodeInfo.getSettings().getByPrefix("thread_pool.index.").isEmpty() == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ public void testHttpEnabledCheck() {
assertSettingsAndIssue("http.enabled", Boolean.toString(randomBoolean()), expected);
}

public void testAuditLoggingPrefixSettingsCheck() {
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Audit log node info settings renamed",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_70_cluster_changes.html" +
"#audit-logfile-local-node-info",
"nodes with audit log settings that have been renamed: [node_check]");
assertSettingsAndIssue("xpack.security.audit.logfile.prefix.emit_node_host_address", Boolean.toString(randomBoolean()), expected);
assertSettingsAndIssue("xpack.security.audit.logfile.prefix.emit_node_host_name", Boolean.toString(randomBoolean()), expected);
assertSettingsAndIssue("xpack.security.audit.logfile.prefix.emit_node_name", Boolean.toString(randomBoolean()), expected);
}

public void testIndexThreadPoolCheck() {
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Index thread pool removed in favor of combined write thread pool",
Expand Down

0 comments on commit 7dbc28f

Please sign in to comment.