diff --git a/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.test.ts b/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.test.ts index 01d6a2e2e81bc..572d73e368c7a 100644 --- a/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.test.ts +++ b/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.test.ts @@ -140,4 +140,21 @@ describe('dedupeConnections', () => { // @ts-ignore expect(nodejsNode?.data[SPAN_SUBTYPE]).toBe('aa'); }); + + it('processes connections without a matching "service" aggregation', () => { + const response: ServiceMapResponse = { + services: [javaService], + discoveredServices: [], + connections: [ + { + source: javaService, + destination: nodejsService + } + ] + }; + + const { elements } = dedupeConnections(response); + + expect(elements.length).toBe(3); + }); }); diff --git a/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.ts b/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.ts index 6a433367d8217..e5d7c0b2de10c 100644 --- a/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.ts +++ b/x-pack/plugins/apm/server/lib/service_map/dedupe_connections/index.ts @@ -88,7 +88,7 @@ export function dedupeConnections(response: ServiceMapResponse) { serviceName = node[SERVICE_NAME]; } - const matchedServiceNodes = services.filter( + const matchedServiceNodes = serviceNodes.filter( serviceNode => serviceNode[SERVICE_NAME] === serviceName ); diff --git a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts index 7fd8b4a894989..a204bd44901b7 100644 --- a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts +++ b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.test.ts @@ -112,6 +112,40 @@ describe('cluster_serialization', () => { }, 'localhost:9300' ) + ).toEqual({ + name: 'test_cluster', + proxyAddress: 'localhost:9300', + mode: 'proxy', + hasDeprecatedProxySetting: true, + isConnected: true, + connectedNodesCount: 1, + maxConnectionsPerCluster: 3, + initialConnectTimeout: '30s', + skipUnavailable: false, + transportPingSchedule: '-1', + transportCompress: false, + }); + }); + + it('should deserialize a cluster that contains a deprecated proxy address and is in cloud', () => { + expect( + deserializeCluster( + 'test_cluster', + { + seeds: ['localhost:9300'], + connected: true, + num_nodes_connected: 1, + max_connections_per_cluster: 3, + initial_connect_timeout: '30s', + skip_unavailable: false, + transport: { + ping_schedule: '-1', + compress: false, + }, + }, + 'localhost:9300', + true + ) ).toEqual({ name: 'test_cluster', proxyAddress: 'localhost:9300', diff --git a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts index 3d8ffa13b8218..07dbe8da28d8a 100644 --- a/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts +++ b/x-pack/plugins/remote_clusters/common/lib/cluster_serialization.ts @@ -68,7 +68,8 @@ export interface ClusterSettingsPayloadEs { export function deserializeCluster( name: string, esClusterObject: ClusterInfoEs, - deprecatedProxyAddress?: string | undefined + deprecatedProxyAddress?: string | undefined, + isCloudEnabled?: boolean | undefined ): Cluster { if (!name || !esClusterObject || typeof esClusterObject !== 'object') { throw new Error('Unable to deserialize cluster'); @@ -117,7 +118,7 @@ export function deserializeCluster( // If a user has a remote cluster with the deprecated proxy setting, // we transform the data to support the new implementation and also flag the deprecation if (deprecatedProxyAddress) { - // Create server name (address, without port), since field doesn't exist in deprecated implementation + // Cloud-specific logic: Create default server name, since field doesn't exist in deprecated implementation const defaultServerName = deprecatedProxyAddress.split(':')[0]; deserializedClusterObject = { @@ -126,7 +127,7 @@ export function deserializeCluster( seeds: undefined, hasDeprecatedProxySetting: true, mode: PROXY_MODE, - serverName: defaultServerName, + serverName: isCloudEnabled ? defaultServerName : undefined, }; } diff --git a/x-pack/plugins/remote_clusters/kibana.json b/x-pack/plugins/remote_clusters/kibana.json index 8922bf621aa03..f1b9d20f762d3 100644 --- a/x-pack/plugins/remote_clusters/kibana.json +++ b/x-pack/plugins/remote_clusters/kibana.json @@ -11,7 +11,8 @@ "indexManagement" ], "optionalPlugins": [ - "usageCollection" + "usageCollection", + "cloud" ], "server": true, "ui": true diff --git a/x-pack/plugins/remote_clusters/public/application/app_context.tsx b/x-pack/plugins/remote_clusters/public/application/app_context.tsx new file mode 100644 index 0000000000000..86c0b401d416d --- /dev/null +++ b/x-pack/plugins/remote_clusters/public/application/app_context.tsx @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React, { createContext } from 'react'; + +export interface Context { + isCloudEnabled: boolean; +} + +export const AppContext = createContext({} as any); + +export const AppContextProvider = ({ + children, + context, +}: { + children: React.ReactNode; + context: Context; +}) => { + return {children}; +}; diff --git a/x-pack/plugins/remote_clusters/public/application/index.d.ts b/x-pack/plugins/remote_clusters/public/application/index.d.ts index b5c5ad5522134..b021dca51bacd 100644 --- a/x-pack/plugins/remote_clusters/public/application/index.d.ts +++ b/x-pack/plugins/remote_clusters/public/application/index.d.ts @@ -8,5 +8,8 @@ import { RegisterManagementAppArgs, I18nStart } from '../types'; export declare const renderApp: ( elem: HTMLElement | null, - I18nContext: I18nStart['Context'] + I18nContext: I18nStart['Context'], + appDependencies: { + isCloudEnabled?: boolean; + } ) => ReturnType; diff --git a/x-pack/plugins/remote_clusters/public/application/index.js b/x-pack/plugins/remote_clusters/public/application/index.js index 0b8b26ace5daa..f2d788c741342 100644 --- a/x-pack/plugins/remote_clusters/public/application/index.js +++ b/x-pack/plugins/remote_clusters/public/application/index.js @@ -11,14 +11,17 @@ import { Provider } from 'react-redux'; import { App } from './app'; import { remoteClustersStore } from './store'; +import { AppContextProvider } from './app_context'; -export const renderApp = (elem, I18nContext) => { +export const renderApp = (elem, I18nContext, appDependencies) => { render( - - - + + + + + , elem diff --git a/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap index 6ff8c538ca89c..4c109c557fdb0 100644 --- a/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap +++ b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap @@ -5,7 +5,6 @@ exports[`RemoteClusterForm proxy mode renders correct connection settings when u disabledFields={Object {}} fields={ Object { - "mode": "sniff", "name": "", "nodeConnections": 3, "proxyAddress": "", @@ -805,6 +804,7 @@ exports[`RemoteClusterForm proxy mode renders correct connection settings when u data-test-subj="remoteClusterFormServerNameFormRow" describedByIds={Array []} display="row" + error={null} fullWidth={true} hasChildLabel={true} hasEmptyLabelSpace={false} @@ -827,10 +827,11 @@ exports[`RemoteClusterForm proxy mode renders correct connection settings when u } /> } + isInvalid={false} label={ } @@ -845,18 +846,21 @@ exports[`RemoteClusterForm proxy mode renders correct connection settings when u className="euiFormRow__labelWrapper" >