Skip to content

Commit b95df28

Browse files
authored
Adding deprecation info API check for client transport profile setting (#76999)
In 8.0, access to the transport client has been removed, so the transport.profiles.*.xpack.security.type setting is gone. This commit adds a deprecation info API check for this property. Relates #42404 #43236
1 parent e8bb9ea commit b95df28

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private DeprecationChecks() {
9797
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
9898
NodeDeprecationChecks::checkSearchRemoteSettings,
9999
NodeDeprecationChecks::checkMonitoringExporterPassword,
100+
NodeDeprecationChecks::checkTransportClientProfilesFilterSetting,
100101
NodeDeprecationChecks::checkDelayClusterStateRecoverySettings,
101102
NodeDeprecationChecks::checkFixedAutoQueueSizeThreadpool,
102103
NodeDeprecationChecks::checkJoinTimeoutSetting,

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

+32
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,38 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
666666
);
667667
}
668668

669+
static DeprecationIssue checkTransportClientProfilesFilterSetting(
670+
final Settings settings,
671+
final PluginsAndModules pluginsAndModules,
672+
ClusterState cs,
673+
XPackLicenseState licenseState
674+
) {
675+
final Setting.AffixSetting<String> transportTypeProfileSetting =
676+
Setting.affixKeySetting("transport.profiles.","xpack.security.type", s -> Setting.simpleString(s));
677+
List<Setting<?>> transportProfiles = transportTypeProfileSetting.getAllConcreteSettings(settings)
678+
.sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList());
679+
680+
if (transportProfiles.isEmpty()) {
681+
return null;
682+
}
683+
684+
final String transportProfilesSettings = transportProfiles.stream().map(Setting::getKey).collect(Collectors.joining(","));
685+
final String message = String.format(
686+
Locale.ROOT,
687+
"settings [%s] are deprecated and will be removed in the next major version",
688+
transportProfilesSettings
689+
);
690+
final String details = String.format(
691+
Locale.ROOT,
692+
"transport client will be removed in the next major version so transport client related settings [%s] must be removed",
693+
transportProfilesSettings
694+
);
695+
696+
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0" +
697+
".html#separating-node-and-client-traffic";
698+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
699+
}
700+
669701
static DeprecationIssue checkDelayClusterStateRecoverySettings(final Settings settings,
670702
final PluginsAndModules pluginsAndModules,
671703
final ClusterState clusterState,

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

+38
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,44 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
962962
assertThat(issues, empty());
963963
}
964964

965+
public void testCheckTransportClientProfilesFilterSetting() {
966+
final int numProfiles = randomIntBetween(1, 3);
967+
final String[] profileNames = new String[numProfiles];
968+
final Settings.Builder b = Settings.builder();
969+
for (int k = 0; k < numProfiles; k++) {
970+
profileNames[k] = randomAlphaOfLength(5);
971+
b.put("transport.profiles." + profileNames[k] + ".xpack.security.type", randomAlphaOfLengthBetween(3, 10));
972+
}
973+
final Settings settings = b.build();
974+
final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0);
975+
DeprecationIssue issue = NodeDeprecationChecks.checkTransportClientProfilesFilterSetting(settings, null, null, licenseState);
976+
final String expectedUrl =
977+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#separating-node-and-client-traffic";
978+
final String joinedNames = Arrays
979+
.stream(profileNames)
980+
.map(s -> "transport.profiles." + s + ".xpack.security.type")
981+
.sorted()
982+
.collect(Collectors.joining(","));
983+
984+
assertThat(issue, equalTo(new DeprecationIssue(
985+
DeprecationIssue.Level.CRITICAL,
986+
String.format(
987+
Locale.ROOT,
988+
"settings [%s] are deprecated and will be removed in the next major version",
989+
joinedNames
990+
),
991+
expectedUrl,
992+
String.format(
993+
Locale.ROOT,
994+
"transport client will be removed in the next major version so transport client related settings [%s] must be removed",
995+
joinedNames
996+
), false, null)));
997+
998+
// test for absence of deprecated exporter passwords
999+
issue = NodeDeprecationChecks.checkTransportClientProfilesFilterSetting(Settings.builder().build(), null, null, licenseState);
1000+
assertThat(issue, nullValue());
1001+
}
1002+
9651003
public void testCheckDelayClusterStateRecoverySettings() {
9661004
Settings settings = Settings.builder()
9671005
.put(GatewayService.EXPECTED_NODES_SETTING.getKey(), randomIntBetween(2, 10))

0 commit comments

Comments
 (0)