Skip to content
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

[Remote clusters] Adopt changes to remote info API #60795

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ describe('cluster_serialization', () => {
expect(() => deserializeCluster('foo', 'bar')).toThrowError();
});

it('should deserialize a complete cluster object', () => {
it('should deserialize a complete default cluster object', () => {
expect(
deserializeCluster('test_cluster', {
seeds: ['localhost:9300'],
connected: true,
mode: 'sniff',
num_nodes_connected: 1,
max_connections_per_cluster: 3,
initial_connect_timeout: '30s',
Expand All @@ -29,6 +30,7 @@ describe('cluster_serialization', () => {
})
).toEqual({
name: 'test_cluster',
mode: 'sniff',
seeds: ['localhost:9300'],
isConnected: true,
connectedNodesCount: 1,
Expand All @@ -40,6 +42,37 @@ describe('cluster_serialization', () => {
});
});

it('should deserialize a complete "proxy" mode cluster object', () => {
expect(
deserializeCluster('test_cluster', {
proxy_address: 'localhost:9300',
mode: 'proxy',
connected: true,
num_proxy_sockets_connected: 1,
max_proxy_socket_connections: 3,
initial_connect_timeout: '30s',
skip_unavailable: false,
server_name: 'my_server_name',
transport: {
ping_schedule: '-1',
compress: false,
},
})
).toEqual({
name: 'test_cluster',
mode: 'proxy',
proxyAddress: 'localhost:9300',
isConnected: true,
connectedSocketsCount: 1,
proxySocketConnections: 3,
initialConnectTimeout: '30s',
skipUnavailable: false,
transportPingSchedule: '-1',
transportCompress: false,
serverName: 'my_server_name',
});
});

it('should deserialize a cluster object without transport information', () => {
expect(
deserializeCluster('test_cluster', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ export interface ClusterEs {
ping_schedule?: string;
compress?: boolean;
};
address?: string;
max_socket_connections?: number;
num_sockets_connected?: number;
proxy_address?: string;
max_proxy_socket_connections?: number;
num_proxy_sockets_connected?: number;
server_name?: string;
}

export interface Cluster {
Expand Down Expand Up @@ -77,9 +78,10 @@ export function deserializeCluster(
initial_connect_timeout: initialConnectTimeout,
skip_unavailable: skipUnavailable,
transport,
address: proxyAddress,
max_socket_connections: proxySocketConnections,
num_sockets_connected: connectedSocketsCount,
proxy_address: proxyAddress,
max_proxy_socket_connections: proxySocketConnections,
num_proxy_sockets_connected: connectedSocketsCount,
server_name: serverName,
} = esClusterObject;

let deserializedClusterObject: Cluster = {
Expand All @@ -94,6 +96,7 @@ export function deserializeCluster(
proxyAddress,
proxySocketConnections,
connectedSocketsCount,
serverName,
};

if (transport) {
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugins/remote_clusters/server/routes/api/get_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,9 @@ export const register = (deps: RouteDependencies): void => {
? get(clusterSettings, `persistent.cluster.remote[${clusterName}].proxy`, undefined)
: undefined;

// server_name is not available via the GET /_remote/info API, so we get it from the cluster settings
// Per https://github.com/elastic/kibana/pull/26067#issuecomment-441848124, we only look at persistent settings
const serverName = isPersistent
? get(clusterSettings, `persistent.cluster.remote[${clusterName}].server_name`, undefined)
: undefined;

return {
...deserializeCluster(clusterName, cluster, deprecatedProxyAddress),
isConfiguredByNode,
serverName,
};
});

Expand Down