Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ const MLJobsAwaitingNodeWarning: FC<Props> = ({ jobIds }) => {
try {
const resp = await ml.mlInfo();
const cloudId = resp.cloudId ?? null;
const isCloudTrial = resp.isCloudTrial === true;
setCloudInfo({
isCloud: cloudId !== null,
cloudId,
isCloudTrial,
deploymentId: cloudId === null ? null : extractDeploymentId(cloudId),
});
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"limits": {
"max_model_memory_limit": "128mb"
},
"cloudId": "cloud_message_test:ZXUtd2VzdC0yLmF3cy5jbG91ZC5lcy5pbyQ4NWQ2NjZmMzM1MGM0NjllOGMzMjQyZDc2YTdmNDU5YyQxNmI1ZDM2ZGE1Mzk0YjlkYjIyZWJlNDk1OWY1OGQzMg=="
"cloudId": "cloud_message_test:ZXUtd2VzdC0yLmF3cy5jbG91ZC5lcy5pbyQ4NWQ2NjZmMzM1MGM0NjllOGMzMjQyZDc2YTdmNDU5YyQxNmI1ZDM2ZGE1Mzk0YjlkYjIyZWJlNDk1OWY1OGQzMg==",
"isCloudTrial": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface MlInfoResponse {
};
upgrade_mode: boolean;
cloudId?: string;
isCloudTrial?: boolean;
}

export interface BucketSpanEstimatorResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
loadMlServerInfo,
getCloudDeploymentId,
isCloud,
isCloudTrial,
getNewJobDefaults,
getNewJobLimits,
extractDeploymentId,
Expand All @@ -34,8 +35,9 @@ describe('ml_server_info', () => {
});

describe('cloud information', () => {
it('should get could deployment id', () => {
it('should get could deployment id and trial info', () => {
expect(isCloud()).toBe(true);
expect(isCloudTrial()).toBe(true);
expect(getCloudDeploymentId()).toBe('85d666f3350c469e8c3242d76a7f459c');
});
});
Expand Down
10 changes: 9 additions & 1 deletion x-pack/plugins/ml/public/application/services/ml_server_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MlServerDefaults, MlServerLimits } from '../../../common/types/ml_serve
export interface CloudInfo {
cloudId: string | null;
isCloud: boolean;
isCloudTrial: boolean;
deploymentId: string | null;
}

Expand All @@ -23,6 +24,7 @@ let limits: MlServerLimits = {};
const cloudInfo: CloudInfo = {
cloudId: null,
isCloud: false,
isCloudTrial: false,
deploymentId: null,
};

Expand All @@ -31,9 +33,11 @@ export async function loadMlServerInfo() {
const resp = await ml.mlInfo();
defaults = resp.defaults;
limits = resp.limits;
cloudInfo.cloudId = resp.cloudId || null;
cloudInfo.cloudId = resp.cloudId ?? null;
cloudInfo.isCloud = resp.cloudId !== undefined;
cloudInfo.isCloudTrial = resp.isCloudTrial === true;
cloudInfo.deploymentId = !resp.cloudId ? null : extractDeploymentId(resp.cloudId);

return { defaults, limits, cloudId: cloudInfo };
} catch (error) {
return { defaults, limits, cloudId: cloudInfo };
Expand All @@ -56,6 +60,10 @@ export function isCloud(): boolean {
return cloudInfo.isCloud;
}

export function isCloudTrial(): boolean {
return cloudInfo.isCloudTrial;
}

export function getCloudDeploymentId(): string | null {
return cloudInfo.deploymentId;
}
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/ml/server/routes/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ export function systemRoutes(
routeGuard.basicLicenseAPIGuard(async ({ mlClient, response }) => {
try {
const body = await mlClient.info();
const cloudId = cloud && cloud.cloudId;
const cloudId = cloud?.cloudId;
const isCloudTrial = cloud?.trialEndDate && Date.now() < cloud.trialEndDate.getTime();

return response.ok({
body: { ...body, cloudId },
body: { ...body, cloudId, isCloudTrial },
});
} catch (error) {
return response.customError(wrapError(error));
Expand Down