Skip to content

Commit d7f992b

Browse files
authored
Remove escape hatch permitting incompatible builds (#76513)
The system property "es.unsafely_permit_handshake_from_incompatible_builds" was deprecated and has been removed in 8.0. This adds a deprecation check for that property. Relates to #42404 and #65753.
1 parent 029ea4a commit d7f992b

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

server/src/main/java/org/elasticsearch/transport/TransportService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class TransportService extends AbstractLifecycleComponent
7070

7171
private static final Logger logger = LogManager.getLogger(TransportService.class);
7272

73-
private static final String PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY = "es.unsafely_permit_handshake_from_incompatible_builds";
73+
public static final String PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY = "es.unsafely_permit_handshake_from_incompatible_builds";
7474
private static final boolean PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS;
7575

7676
static {

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

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.cluster.node.DiscoveryNode;
1313
import org.elasticsearch.common.settings.Settings;
1414
import org.elasticsearch.license.XPackLicenseState;
15+
import org.elasticsearch.transport.TransportService;
1516
import org.elasticsearch.xpack.core.XPackSettings;
1617

1718
import java.util.Arrays;
@@ -97,6 +98,10 @@ private DeprecationChecks() {
9798
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
9899
NodeDeprecationChecks::checkSearchRemoteSettings,
99100
NodeDeprecationChecks::checkMonitoringExporterPassword,
101+
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
102+
(settings, pluginsAndModules, clusterState, licenseState) ->
103+
NodeDeprecationChecks.checkNoPermitHandshakeFromIncompatibleBuilds(settings, pluginsAndModules, clusterState,
104+
licenseState, () -> System.getProperty(TransportService.PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY)),
100105
NodeDeprecationChecks::checkTransportClientProfilesFilterSetting,
101106
NodeDeprecationChecks::checkDelayClusterStateRecoverySettings,
102107
NodeDeprecationChecks::checkFixedAutoQueueSizeThreadpool,

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

+25
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.threadpool.FixedExecutorBuilder;
3636
import org.elasticsearch.transport.RemoteClusterService;
3737
import org.elasticsearch.transport.SniffConnectionStrategy;
38+
import org.elasticsearch.transport.TransportService;
3839
import org.elasticsearch.xpack.core.XPackSettings;
3940
import org.elasticsearch.xpack.core.security.SecurityField;
4041
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
@@ -51,6 +52,7 @@
5152
import java.util.Optional;
5253
import java.util.Set;
5354
import java.util.function.BiFunction;
55+
import java.util.function.Supplier;
5456
import java.util.stream.Collectors;
5557

5658
import static org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING;
@@ -666,6 +668,29 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
666668
);
667669
}
668670

671+
static DeprecationIssue checkNoPermitHandshakeFromIncompatibleBuilds(final Settings settings,
672+
final PluginsAndModules pluginsAndModules,
673+
final ClusterState clusterState,
674+
final XPackLicenseState licenseState,
675+
Supplier<String> permitsHandshakesFromIncompatibleBuildsSupplier) {
676+
if (permitsHandshakesFromIncompatibleBuildsSupplier.get() != null) {
677+
final String message = String.format(
678+
Locale.ROOT,
679+
"the [%s] system property is deprecated and will be removed in the next major release",
680+
TransportService.PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY
681+
);
682+
final String details = String.format(
683+
Locale.ROOT,
684+
"allowing handshakes from incompatibile builds is deprecated and will be removed in the next major release; the [%s] " +
685+
"system property must be removed",
686+
TransportService.PERMIT_HANDSHAKES_FROM_INCOMPATIBLE_BUILDS_KEY
687+
);
688+
String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_transport_changes";
689+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
690+
}
691+
return null;
692+
}
693+
669694
static DeprecationIssue checkTransportClientProfilesFilterSetting(
670695
final Settings settings,
671696
final PluginsAndModules pluginsAndModules,

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

+22
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.elasticsearch.common.settings.Settings;
2222
import org.elasticsearch.common.util.concurrent.EsExecutors;
2323
import org.elasticsearch.core.Set;
24+
import org.elasticsearch.core.SuppressForbidden;
2425
import org.elasticsearch.env.Environment;
2526
import org.elasticsearch.env.NodeEnvironment;
2627
import org.elasticsearch.gateway.GatewayService;
@@ -962,6 +963,27 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
962963
assertThat(issues, empty());
963964
}
964965

966+
@SuppressForbidden(reason = "sets and unsets es.unsafely_permit_handshake_from_incompatible_builds")
967+
public void testCheckNoPermitHandshakeFromIncompatibleBuilds() {
968+
final DeprecationIssue expectedNullIssue =
969+
NodeDeprecationChecks.checkNoPermitHandshakeFromIncompatibleBuilds(Settings.EMPTY,
970+
null,
971+
ClusterState.EMPTY_STATE,
972+
new XPackLicenseState(Settings.EMPTY, () -> 0),
973+
() -> null);
974+
assertEquals(null, expectedNullIssue);
975+
final DeprecationIssue issue =
976+
NodeDeprecationChecks.checkNoPermitHandshakeFromIncompatibleBuilds(Settings.EMPTY,
977+
null,
978+
ClusterState.EMPTY_STATE,
979+
new XPackLicenseState(Settings.EMPTY, () -> 0),
980+
() -> randomAlphaOfLengthBetween(1, 10));
981+
assertNotNull(issue.getDetails());
982+
assertThat(issue.getDetails(), containsString("system property must be removed"));
983+
assertThat(issue.getUrl(),
984+
equalTo("https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_transport_changes"));
985+
}
986+
965987
public void testCheckTransportClientProfilesFilterSetting() {
966988
final int numProfiles = randomIntBetween(1, 3);
967989
final String[] profileNames = new String[numProfiles];

0 commit comments

Comments
 (0)