Skip to content

Commit

Permalink
[Remote clustersadopt changes to remote info API (elastic#60795)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Mar 23, 2020
1 parent 0ef9835 commit b76dc4e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
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

0 comments on commit b76dc4e

Please sign in to comment.