Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(opensearchservice): configuring gp3 throughput #26172

Merged

Conversation

sktan
Copy link
Contributor

@sktan sktan commented Jun 29, 2023

The interface EbsOptions for the opensearchservices CDK construct is missing a provisioned throughput option for eg gp3 instance types.
iops is there, but not throughput

Closes #26137.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Jun 29, 2023

@sktan sktan changed the title feat(aws-opensearchservice): Support gp3 throughput configuration when configuring an opensearch domain feat(opensearchservice): Support gp3 throughput configuration when configuring an opensearch domain Jun 29, 2023
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Jun 29, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 29, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team June 29, 2023 19:40
@@ -1575,6 +1583,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
volumeSize: ebsEnabled ? volumeSize : undefined,
volumeType: ebsEnabled ? volumeType : undefined,
iops: ebsEnabled ? props.ebs?.iops : undefined,
throughput: ebsEnabled ? props.ebs?.throughput : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like we have any check on the volumeType. It says iops and
throughput are only supported for iops/gp3 types, but we only check if it's ebs
type?

Do you know what happens if throughput is defined for gp2 volumes? Does it
just ignore that property or does it throw an error?

I think we need something like what we have in the volume construct

// Enforce maximum ratio of IOPS/GiB:
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html
const maximumRatios: { [key: string]: number } = {};
maximumRatios[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3] = 500;
maximumRatios[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD] = 50;
maximumRatios[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2] = 500;
const maximumRatio = maximumRatios[volumeType];
if (props.size && (props.iops > maximumRatio * props.size.toGibibytes({ rounding: SizeRoundingBehavior.FAIL }))) {
throw new Error(`\`${volumeType}\` volumes iops has a maximum ratio of ${maximumRatio} IOPS/GiB.`);
}
const maximumThroughputRatios: { [key: string]: number } = {};
maximumThroughputRatios[EbsDeviceVolumeType.GP3] = 0.25;
const maximumThroughputRatio = maximumThroughputRatios[volumeType];
if (props.throughput && props.iops) {
const iopsRatio = (props.throughput / props.iops);
if (iopsRatio > maximumThroughputRatio) {
throw new Error(`Throughput (MiBps) to iops ratio of ${iopsRatio} is too high; maximum is ${maximumThroughputRatio} MiBps per iops`);
}
}
}
if (props.enableMultiAttach) {
const volumeType = props.volumeType ?? EbsDeviceVolumeType.GENERAL_PURPOSE_SSD;
if (
![
EbsDeviceVolumeType.PROVISIONED_IOPS_SSD,
EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2,
].includes(volumeType)
) {
throw new Error('multi-attach is supported exclusively on `PROVISIONED_IOPS_SSD` and `PROVISIONED_IOPS_SSD_IO2` volumes.');
}
}
if (props.size) {
const size = props.size.toGibibytes({ rounding: SizeRoundingBehavior.FAIL });
// Enforce minimum & maximum volume size:
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html
const sizeRanges: { [key: string]: { Min: number, Max: number } } = {};
sizeRanges[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD] = { Min: 1, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3] = { Min: 1, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD] = { Min: 4, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2] = { Min: 4, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.THROUGHPUT_OPTIMIZED_HDD] = { Min: 125, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.COLD_HDD] = { Min: 125, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.MAGNETIC] = { Min: 1, Max: 1024 };
const volumeType = props.volumeType ?? EbsDeviceVolumeType.GENERAL_PURPOSE_SSD;
const { Min, Max } = sizeRanges[volumeType];
if (size < Min || size > Max) {
throw new Error(`\`${volumeType}\` volumes must be between ${Min} GiB and ${Max} GiB in size.`);
}
}
if (props.throughput) {
const throughputRange = { Min: 125, Max: 1000 };
const { Min, Max } = throughputRange;
if (props.volumeType != EbsDeviceVolumeType.GP3) {
throw new Error(
'throughput property requires volumeType: EbsDeviceVolumeType.GP3',
);
}
if (props.throughput < Min || props.throughput > Max) {
throw new Error(
`throughput property takes a minimum of ${Min} and a maximum of ${Max}`,
);
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think about checks specification checks, the other option for iops didn't any checks defined so I didn't it for the throughput option`. I'll get that sorted in the next commit :)

Copy link
Contributor Author

@sktan sktan Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a bunch of tests and validation checks for you @corymhall , let me know if there's anything i've missed.

@corymhall corymhall removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 30, 2023
@mergify mergify bot dismissed corymhall’s stale review July 4, 2023 19:00

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 5, 2023
@sktan sktan requested a review from corymhall July 5, 2023 01:51
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@jumic
Copy link
Contributor

jumic commented Jul 24, 2023

@sktan The last build failed. Do you need help?
If the build is successful locally and only failed in this PR: Merge branch main into your branch to trigger a new build.

@sktan
Copy link
Contributor Author

sktan commented Jul 25, 2023

@sktan The last build failed. Do you need help? If the build is successful locally and only failed in this PR: Merge branch main into your branch to trigger a new build.

Hey, thanks for the offer @jumic. I haven't gotten around to fixing it just yet, it failed due to another PR making a change to the default parameters causing my integration test to provide a CHANGED result.

This will get sorted soon

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

3 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@sktan
Copy link
Contributor Author

sktan commented Aug 7, 2023

@corymhall we should be good to go again for this PR

// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-opensearchservice-domain-ebsoptions.html
if (ebsEnabled) {
// Check if iops or throughput if general purpose is configured
if (volumeType == ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD || volumeType == ec2.EbsDeviceVolumeType.STANDARD) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (volumeType == ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD || volumeType == ec2.EbsDeviceVolumeType.STANDARD) {
if (volumeType === ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD || volumeType === ec2.EbsDeviceVolumeType.STANDARD) {

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 18, 2023
@rix0rrr rix0rrr changed the title feat(opensearchservice): Support gp3 throughput configuration when configuring an opensearch domain feat(opensearchservice): configuring gp3 throughput Aug 22, 2023
rix0rrr
rix0rrr previously approved these changes Aug 22, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 22, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot dismissed rix0rrr’s stale review August 22, 2023 12:58

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Aug 22, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: d51f153
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 47df704 into aws:main Aug 22, 2023
9 checks passed
@mergify
Copy link
Contributor

mergify bot commented Aug 22, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@sktan sktan deleted the feat/aws-opensearchservice/ebsoptionsthroughput branch August 23, 2023 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opensearch: add throughput to EbsOptions
6 participants