[ML] Correcting the size of the free ML node on cloud (#144512)

This commit is contained in:
James Gowdy 2022-11-04 13:02:28 +00:00 committed by GitHub
parent caffde0fe9
commit 0c0079f221
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View file

@ -5,4 +5,5 @@
* 2.0.
*/
export const PLATINUM_MAX_RAM_FOR_ML_NODES = '1GB';
export const TRIAL_MAX_RAM_FOR_ML_NODES = '2GB';

View file

@ -11,6 +11,7 @@ import { PLUGIN_ID } from '../constants/app';
export const MINIMUM_LICENSE = 'basic';
export const MINIMUM_FULL_LICENSE = 'platinum';
export const TRIAL_LICENSE = 'trial';
export interface LicenseStatus {
isValid: boolean;
@ -26,6 +27,7 @@ export class MlLicense {
private _isMlEnabled: boolean = false;
private _isMinimumLicense: boolean = false;
private _isFullLicense: boolean = false;
private _isTrialLicense: boolean = false;
private _initialized: boolean = false;
public setup(
@ -41,6 +43,7 @@ export class MlLicense {
this._isMlEnabled = this._license.getFeature(PLUGIN_ID).isEnabled;
this._isMinimumLicense = isMinimumLicense(this._license);
this._isFullLicense = isFullLicense(this._license);
this._isTrialLicense = isTrialLicense(this._license);
if (this._initialized === false && postInitFunctions !== undefined) {
postInitFunctions.forEach((f) => f(this));
@ -74,12 +77,20 @@ export class MlLicense {
public isFullLicense() {
return this._isFullLicense;
}
public isTrialLicense() {
return this._isTrialLicense;
}
}
export function isFullLicense(license: ILicense) {
return license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === 'valid';
}
export function isTrialLicense(license: ILicense) {
return license.check(PLUGIN_ID, TRIAL_LICENSE).state === 'valid';
}
export function isMinimumLicense(license: ILicense) {
return license.check(PLUGIN_ID, MINIMUM_LICENSE).state === 'valid';
}

View file

@ -11,13 +11,21 @@ import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { mlNodesAvailable, permissionToViewMlNodeCount } from '../../ml_nodes_check';
import { getCloudDeploymentId, isCloud } from '../../services/ml_server_info';
import { TRIAL_MAX_RAM_FOR_ML_NODES } from '../../../../common/constants/cloud';
import {
TRIAL_MAX_RAM_FOR_ML_NODES,
PLATINUM_MAX_RAM_FOR_ML_NODES,
} from '../../../../common/constants/cloud';
import { isTrialLicense } from '../../license/check_license';
export const NodeAvailableWarning: FC = () => {
if (mlNodesAvailable() === true || permissionToViewMlNodeCount() === false) {
return null;
}
const maxRamForMLNodes = isTrialLicense()
? TRIAL_MAX_RAM_FOR_ML_NODES
: PLATINUM_MAX_RAM_FOR_ML_NODES;
const id = getCloudDeploymentId();
return (
<Fragment>
@ -57,7 +65,7 @@ export const NodeAvailableWarning: FC = () => {
/>
</EuiLink>
),
maxRamForMLNodes: TRIAL_MAX_RAM_FOR_ML_NODES,
maxRamForMLNodes,
}}
/>
</div>

View file

@ -84,3 +84,13 @@ export function hasLicenseExpired() {
export function isFullLicense() {
return mlLicense !== null && mlLicense.isFullLicense();
}
/**
* Check to see if the current license is trial.
*
* @export
* @returns {boolean}
*/
export function isTrialLicense() {
return mlLicense !== null && mlLicense.isTrialLicense();
}