[Remote clustersadopt changes to remote info API (#60795)

This commit is contained in:
Alison Goryachev 2020-03-23 10:42:40 -04:00 committed by GitHub
parent 42539a56eb
commit 8572e3f18f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 14 deletions

View file

@ -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',
@ -29,6 +30,7 @@ describe('cluster_serialization', () => {
})
).toEqual({
name: 'test_cluster',
mode: 'sniff',
seeds: ['localhost:9300'],
isConnected: true,
connectedNodesCount: 1,
@ -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', {

View file

@ -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 {
@ -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 = {
@ -94,6 +96,7 @@ export function deserializeCluster(
proxyAddress,
proxySocketConnections,
connectedSocketsCount,
serverName,
};
if (transport) {

View file

@ -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,
};
});