Skip to content

Commit

Permalink
[ML] Adding cloud specific ML node warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Nov 11, 2019
1 parent d86b6c7 commit 554fef7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AggFieldNamePair } from '../../../common/types/fields';
import { ExistingJobsAndGroups } from '../job_service';
import { PrivilegesResponse } from '../../../common/types/privileges';
import { MlSummaryJobs } from '../../../common/types/jobs';
import { MlServerDefaults, MlServerLimits } from '../../jobs/new_job_new/utils/new_job_defaults';
import { MlServerDefaults, MlServerLimits } from '../ml_server_info';
import { ES_AGGREGATION } from '../../../common/constants/aggregation_types';

// TODO This is not a complete representation of all methods of `ml.*`.
Expand Down Expand Up @@ -54,6 +54,7 @@ export interface MlInfoResponse {
version: string;
};
upgrade_mode: boolean;
cloudId?: string;
}

declare interface Ml {
Expand Down
14 changes: 11 additions & 3 deletions x-pack/legacy/plugins/ml/server/routes/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { isSecurityDisabled } from '../lib/security_utils';
export function systemRoutes({
commonRouteConfig,
elasticsearchPlugin,
config,
route,
xpackMainPlugin,
spacesPlugin
Expand Down Expand Up @@ -168,10 +169,17 @@ export function systemRoutes({
route({
method: 'GET',
path: '/api/ml/info',
handler(request) {
async handler(request) {
const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request);
return callWithRequest('ml.info')
.catch(resp => wrapError(resp));

try {
const info = await callWithRequest('ml.info');
const cloudIdKey = 'xpack.cloud.id';
const cloudId = config.has(cloudIdKey) && config.get(cloudIdKey);
return { ...info, cloudId };
} catch (error) {
return wrapError(error);
}
},
config: {
...commonRouteConfig
Expand Down

0 comments on commit 554fef7

Please sign in to comment.