-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Add warning when remote clusters are configured (#…
- Loading branch information
1 parent
a779590
commit 92c7cf8
Showing
12 changed files
with
273 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { SerializableRecord } from '@kbn/utility-types'; | ||
import { ManagementAppLocator } from 'src/plugins/management/common'; | ||
import { LocatorDefinition } from '../../../../src/plugins/share/public/'; | ||
|
||
export const REMOTE_CLUSTERS_LOCATOR_ID = 'REMOTE_CLUSTERS_LOCATOR'; | ||
|
||
export interface RemoteClustersLocatorParams extends SerializableRecord { | ||
page: 'remoteClusters'; | ||
} | ||
|
||
export interface RemoteClustersLocatorDefinitionDependencies { | ||
managementAppLocator: ManagementAppLocator; | ||
} | ||
|
||
export class RemoteClustersLocatorDefinition | ||
implements LocatorDefinition<RemoteClustersLocatorParams> | ||
{ | ||
constructor(protected readonly deps: RemoteClustersLocatorDefinitionDependencies) {} | ||
|
||
public readonly id = REMOTE_CLUSTERS_LOCATOR_ID; | ||
|
||
public readonly getLocation = async (params: RemoteClustersLocatorParams) => { | ||
const location = await this.deps.managementAppLocator.getLocation({ | ||
sectionId: 'data', | ||
appId: 'remote_clusters', | ||
}); | ||
|
||
switch (params.page) { | ||
case 'remoteClusters': { | ||
return { | ||
...location, | ||
path: location.path, | ||
}; | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/upgrade_assistant/server/routes/remote_clusters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { API_BASE_PATH } from '../../common/constants'; | ||
import { versionCheckHandlerWrapper } from '../lib/es_version_precheck'; | ||
import { RouteDependencies } from '../types'; | ||
|
||
export function registerRemoteClustersRoute({ router, lib: { handleEsError } }: RouteDependencies) { | ||
router.get( | ||
{ | ||
path: `${API_BASE_PATH}/remote_clusters`, | ||
validate: false, | ||
}, | ||
versionCheckHandlerWrapper( | ||
async ( | ||
{ | ||
core: { | ||
elasticsearch: { client }, | ||
}, | ||
}, | ||
request, | ||
response | ||
) => { | ||
try { | ||
const { body: clustersByName } = await client.asCurrentUser.cluster.remoteInfo(); | ||
|
||
const remoteClusters = Object.keys(clustersByName); | ||
|
||
return response.ok({ body: remoteClusters }); | ||
} catch (error) { | ||
return handleEsError({ error, response }); | ||
} | ||
} | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.