-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to resolve the cluster alias of remote cluster connections #91724
Add ability to resolve the cluster alias of remote cluster connections #91724
Conversation
Pinging @elastic/es-security (Team:Security) |
Pinging @elastic/es-distributed (Team:Distributed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This is indeed simpler than the "reverse-lookup" approach we discussed. Deferring to @Tim-Brooks for final approval.
server/src/main/java/org/elasticsearch/transport/RemoteConnectionManager.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/transport/RemoteConnectionManagerTests.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is an issue unwrapping proxy connections.
@@ -87,7 +89,7 @@ public void openConnection(DiscoveryNode node, ConnectionProfile profile, Action | |||
@Override | |||
public Transport.Connection getConnection(DiscoveryNode node) { | |||
try { | |||
return delegate.getConnection(node); | |||
return getConnectionInternal(node); | |||
} catch (NodeNotConnectedException e) { | |||
return new ProxyConnection(getAnyRemoteConnection(), node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the functionality that you want is broken? We do not have a "direct" connection to the target node, the ProxyConnection
type will be returned. But your resolveRemoteClusterAlias
method does not unwrap proxy types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I covered this at line 165 by calling unwrap before checking remote connection type:
elasticsearch/server/src/main/java/org/elasticsearch/transport/RemoteConnectionManager.java
Line 165 in c404382
Transport.Connection unwrapped = TransportService.unwrapConnection(connection); |
Is this okay or do you have something else in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a test specifically for resolving the cluster alias of a proxy connections:
elasticsearch/server/src/test/java/org/elasticsearch/transport/RemoteConnectionManagerTests.java
Lines 104 to 107 in c404382
DiscoveryNode remoteNode2 = new DiscoveryNode("remote-node-2", address, Version.CURRENT); | |
Transport.Connection proxyConnection = remoteConnectionManager.getConnection(remoteNode2); | |
assertThat(proxyConnection, instanceOf(RemoteConnectionManager.ProxyConnection.class)); | |
assertThat(RemoteConnectionManager.resolveRemoteClusterAlias(proxyConnection).get(), equalTo("remote-cluster")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No that's fine. I had just missed that line since it referenced unmodified code.
We introduced the ability to resolve the cluster alias in #91724, given a connection towards a remote cluster. This works for connections obtained via RemoteConnectionManager::getConnection. However, connections can also be initiated via openConnection (e.g., in SniffConnectionStrategy). This PR adds support to correctly resolve the cluster alias for such connections, by wrapping them in an InternalRemoteConnection instance. This is necessary to support the new remote cluster security model.
As part of Remote Cluster Security 2.0, we need to be able to determine
the remote cluster alias for outbound remote cluster connections in the
SecurityServerTransportInterceptor
.This commit adds this ability to
RemoteConnectionManager
by wrapping all created connection objects with cluster alias.