Make it so user cannot create or scale PG server group to 1 worker node (#16005)

* Added not equals validation

* Added validation to worker node in deploy

* Fixed info

* Change string

* Change string

* Change string
This commit is contained in:
nasc17
2021-07-07 12:25:07 -07:00
committed by GitHub
parent 14ce88023e
commit 6078e9f459
5 changed files with 26 additions and 3 deletions

View File

@@ -615,6 +615,11 @@
{
"type": "is_integer",
"description": "%should.be.integer%"
},
{
"type": "!=",
"target": "1",
"description": "%worker.node.count.should.not.be.one%"
}
],
"defaultValue": "2",

View File

@@ -148,6 +148,7 @@
"arc.agreement.sql.terms.conditions": "Azure SQL managed instance - Azure Arc terms and conditions",
"arc.agreement.postgres.terms.conditions": "Azure Arc-enabled PostgreSQL Hyperscale terms and conditions",
"should.be.integer": "Value must be an integer",
"worker.node.count.should.not.be.one": "Value of 1 is not supported.",
"requested.cores.less.than.or.equal.to.cores.limit": "Requested cores must be less than or equal to cores limit",
"cores.limit.greater.than.or.equal.to.requested.cores": "Cores limit must be greater than or equal to requested cores",
"requested.memory.less.than.or.equal.to.memory.limit": "Requested memory must be less than or equal to memory limit",

View File

@@ -83,7 +83,8 @@ export const addingWorkerNodes = localize('arc.addingWorkerNodes', "adding worke
export const workerNodesDescription = localize('arc.workerNodesDescription', "Expand your server group and scale your database by adding worker nodes.");
export const workerNodesConfigurationInformation = localize('arc.workerNodesConfigurationInformation', "You can configure the number of CPU cores and storage size that will apply to all worker nodes. Adjust the number of CPU cores and memory settings for your server group. To reset the requests and/or limits, pass in empty value.");
export const coordinatorNodeConfigurationInformation = localize('arc.coordinatorNodeConfigurationInformation', "You can configure the number of CPU cores and storage size that will apply to the coordinator node. Adjust the number of CPU cores and memory settings for your server group. To reset the requests and/or limits, pass in empty value.");
export const workerNodesInformation = localize('arc.workerNodeInformation', "It is possible to scale in and out your server group by reducing or increasing the number of worker nodes.");
export const workerNodesInformation = localize('arc.workerNodeInformation', "It is possible to scale in and out your server group by reducing or increasing the number of worker nodes. The value must be 0 or greater than 1.");
export const workerOneNodeValidationMessage = localize('arc.workerOneNodeValidationMessage', "Value of 1 is not supported.");
export const vCores = localize('arc.vCores', "vCores");
export const ram = localize('arc.ram', "RAM");
export const refresh = localize('arc.refresh', "Refresh");

View File

@@ -248,7 +248,13 @@ export class PostgresComputeAndStoragePage extends DashboardPage {
inputType: 'number',
placeHolder: loc.loading,
required: true,
ariaLabel: loc.workerNodeCount
ariaLabel: loc.workerNodeCount,
validationErrorMessage: loc.workerOneNodeValidationMessage
}).withValidation((component) => {
if (component.value === '1') {
return false;
}
return true;
}).component();
this.disposables.push(

View File

@@ -25,7 +25,8 @@ export const enum ValidationType {
IsInteger = 'is_integer',
Regex = 'regex_match',
LessThanOrEqualsTo = '<=',
GreaterThanOrEqualsTo = '>='
GreaterThanOrEqualsTo = '>=',
NotEqualTo = '!='
}
export type ValidationInfo = RegexValidationInfo | IntegerValidationInfo | ComparisonValidationInfo;
@@ -175,12 +176,21 @@ export class GreaterThanOrEqualsValidation extends Comparison {
}
}
export class NotEqualValidation extends Comparison {
async isComparisonSuccessful() {
const value = (await this.getValue());
const targetValue = this.target;
return (isUndefinedOrEmpty(value) || isUndefinedOrEmpty(targetValue)) ? true : value!.toString() !== targetValue!;
}
}
export function createValidation(validation: ValidationInfo, valueGetter: ValueGetter, targetValueGetter?: TargetValueGetter, onTargetValidityChangedGetter?: OnTargetValidityChangedGetter, onDisposableCreated?: (disposable: vscode.Disposable) => void): Validation {
switch (validation.type) {
case ValidationType.Regex: return new RegexValidation(<RegexValidationInfo>validation, valueGetter);
case ValidationType.IsInteger: return new IntegerValidation(<IntegerValidationInfo>validation, valueGetter);
case ValidationType.LessThanOrEqualsTo: return new LessThanOrEqualsValidation(<ComparisonValidationInfo>validation, valueGetter, targetValueGetter!, onTargetValidityChangedGetter!, onDisposableCreated!);
case ValidationType.GreaterThanOrEqualsTo: return new GreaterThanOrEqualsValidation(<ComparisonValidationInfo>validation, valueGetter, targetValueGetter!, onTargetValidityChangedGetter!, onDisposableCreated!);
case ValidationType.NotEqualTo: return new NotEqualValidation(<ComparisonValidationInfo>validation, valueGetter, targetValueGetter!, onTargetValidityChangedGetter!, onDisposableCreated!);
default: throw new Error(`unknown validation type:${validation.type}`); //dev error
}
}