Skip to content

Commit

Permalink
Adding deprecation info API check for client transport profile setting (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
masseyke authored Sep 2, 2021
1 parent e8bb9ea commit b95df28
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
NodeDeprecationChecks::checkSearchRemoteSettings,
NodeDeprecationChecks::checkMonitoringExporterPassword,
NodeDeprecationChecks::checkTransportClientProfilesFilterSetting,
NodeDeprecationChecks::checkDelayClusterStateRecoverySettings,
NodeDeprecationChecks::checkFixedAutoQueueSizeThreadpool,
NodeDeprecationChecks::checkJoinTimeoutSetting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,38 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
);
}

static DeprecationIssue checkTransportClientProfilesFilterSetting(
final Settings settings,
final PluginsAndModules pluginsAndModules,
ClusterState cs,
XPackLicenseState licenseState
) {
final Setting.AffixSetting<String> transportTypeProfileSetting =
Setting.affixKeySetting("transport.profiles.","xpack.security.type", s -> Setting.simpleString(s));
List<Setting<?>> transportProfiles = transportTypeProfileSetting.getAllConcreteSettings(settings)
.sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList());

if (transportProfiles.isEmpty()) {
return null;
}

final String transportProfilesSettings = transportProfiles.stream().map(Setting::getKey).collect(Collectors.joining(","));
final String message = String.format(
Locale.ROOT,
"settings [%s] are deprecated and will be removed in the next major version",
transportProfilesSettings
);
final String details = String.format(
Locale.ROOT,
"transport client will be removed in the next major version so transport client related settings [%s] must be removed",
transportProfilesSettings
);

final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0" +
".html#separating-node-and-client-traffic";
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
}

static DeprecationIssue checkDelayClusterStateRecoverySettings(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,44 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
assertThat(issues, empty());
}

public void testCheckTransportClientProfilesFilterSetting() {
final int numProfiles = randomIntBetween(1, 3);
final String[] profileNames = new String[numProfiles];
final Settings.Builder b = Settings.builder();
for (int k = 0; k < numProfiles; k++) {
profileNames[k] = randomAlphaOfLength(5);
b.put("transport.profiles." + profileNames[k] + ".xpack.security.type", randomAlphaOfLengthBetween(3, 10));
}
final Settings settings = b.build();
final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0);
DeprecationIssue issue = NodeDeprecationChecks.checkTransportClientProfilesFilterSetting(settings, null, null, licenseState);
final String expectedUrl =
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#separating-node-and-client-traffic";
final String joinedNames = Arrays
.stream(profileNames)
.map(s -> "transport.profiles." + s + ".xpack.security.type")
.sorted()
.collect(Collectors.joining(","));

assertThat(issue, equalTo(new DeprecationIssue(
DeprecationIssue.Level.CRITICAL,
String.format(
Locale.ROOT,
"settings [%s] are deprecated and will be removed in the next major version",
joinedNames
),
expectedUrl,
String.format(
Locale.ROOT,
"transport client will be removed in the next major version so transport client related settings [%s] must be removed",
joinedNames
), false, null)));

// test for absence of deprecated exporter passwords
issue = NodeDeprecationChecks.checkTransportClientProfilesFilterSetting(Settings.builder().build(), null, null, licenseState);
assertThat(issue, nullValue());
}

public void testCheckDelayClusterStateRecoverySettings() {
Settings settings = Settings.builder()
.put(GatewayService.EXPECTED_NODES_SETTING.getKey(), randomIntBetween(2, 10))
Expand Down

0 comments on commit b95df28

Please sign in to comment.