Skip to content

Commit 9b2ca99

Browse files
authored
Tolerate incompatible versions with different build hash (#128589)
Tolerate incompatible versions with different build hash. I'm keeping the serverless feature flag to not create warnings there. Relates to ES-11869
1 parent 586c3b2 commit 9b2ca99

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,21 +685,21 @@ public HandshakeResponse(StreamInput in) throws IOException {
685685
// message, but recognise that this may fail
686686
discoveryNode = new DiscoveryNode(in);
687687
} catch (Exception e) {
688-
maybeThrowOnIncompatibleBuild(null, e);
688+
maybeWarnOnIncompatibleBuild(null, e);
689689
throw e;
690690
}
691-
maybeThrowOnIncompatibleBuild(discoveryNode, null);
691+
maybeWarnOnIncompatibleBuild(discoveryNode, null);
692692
clusterName = new ClusterName(in);
693693
}
694694

695-
private void maybeThrowOnIncompatibleBuild(@Nullable DiscoveryNode node, @Nullable Exception e) {
695+
private void maybeWarnOnIncompatibleBuild(@Nullable DiscoveryNode node, @Nullable Exception e) {
696696
if (SERVERLESS_TRANSPORT_FEATURE_FLAG == false && isIncompatibleBuild(version, buildHash)) {
697-
throwOnIncompatibleBuild(node, e);
697+
warnOnIncompatibleBuild(node, e);
698698
}
699699
}
700700

701-
private void throwOnIncompatibleBuild(@Nullable DiscoveryNode node, @Nullable Exception e) {
702-
throw new IllegalArgumentException(
701+
private void warnOnIncompatibleBuild(@Nullable DiscoveryNode node, @Nullable Exception e) {
702+
logger.warn(
703703
"remote node ["
704704
+ (node == null ? "unidentifiable" : node)
705705
+ "] is build ["

server/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
package org.elasticsearch.transport;
1111

12+
import org.apache.logging.log4j.Level;
1213
import org.elasticsearch.Build;
13-
import org.elasticsearch.ExceptionsHelper;
1414
import org.elasticsearch.TransportVersion;
1515
import org.elasticsearch.TransportVersions;
1616
import org.elasticsearch.Version;
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.index.IndexVersions;
2828
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
2929
import org.elasticsearch.test.ESTestCase;
30+
import org.elasticsearch.test.MockLog;
3031
import org.elasticsearch.test.TransportVersionUtils;
3132
import org.elasticsearch.test.VersionUtils;
3233
import org.elasticsearch.test.transport.MockTransportService;
@@ -350,23 +351,26 @@ public void testRejectsMismatchedBuildHash() {
350351
.version(Version.CURRENT.minimumCompatibilityVersion(), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current())
351352
.build();
352353
try (
354+
MockLog mockLog = MockLog.capture(TransportService.class);
353355
Transport.Connection connection = AbstractSimpleTransportTestCase.openConnection(
354356
transportServiceA,
355357
discoveryNode,
356358
TestProfiles.LIGHT_PROFILE
357359
)
358360
) {
359-
assertThat(
360-
ExceptionsHelper.unwrap(
361-
safeAwaitFailure(
362-
TransportSerializationException.class,
363-
DiscoveryNode.class,
364-
listener -> transportServiceA.handshake(connection, timeout, listener)
365-
),
366-
IllegalArgumentException.class
367-
).getMessage(),
368-
containsString("which has an incompatible wire format")
361+
mockLog.addExpectation(
362+
new MockLog.SeenEventExpectation(
363+
"message",
364+
TransportService.class.getCanonicalName(),
365+
Level.WARN,
366+
"which has an incompatible wire format"
367+
)
369368
);
369+
370+
DiscoveryNode connectedNode = safeAwait(listener -> transportServiceA.handshake(connection, timeout, listener));
371+
assertNotNull(connectedNode);
372+
373+
mockLog.awaitAllExpectationsMatched();
370374
}
371375
assertFalse(transportServiceA.nodeConnected(discoveryNode));
372376
}

0 commit comments

Comments
 (0)