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

fix(opensearch): add I4I and R7GD to list of OpenSearch nodes not requiring EBS volumes #32592

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mazyu36
Copy link
Contributor

@mazyu36 mazyu36 commented Dec 19, 2024

Issue # (if applicable)

Closes #32070.
Closes #32138.

Reason for this change

I4I and R7GD instances don't require ebs volumes.
But at the moment, a domain with I4I and R7GD instances cannot be deployed.

Description of changes

Added I4I and R7GD to not requiring EBS volumes instances list.

Describe any new or updated permissions being added

Add unit tests and integ tests.
<!— What new or updated IAM permissions are needed to support the changes being introduced ? -->

Description of how you validated changes

Checklist


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

@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Dec 19, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team December 19, 2024 14:12
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Dec 19, 2024
@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 Dec 19, 2024
@@ -1576,8 +1576,8 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {

// Validate against instance type restrictions, per
// https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html
if (isSomeInstanceType('i3', 'r6gd', 'i4g', 'im4gn') && ebsEnabled) {
throw new Error('I3, R6GD, I4G, and IM4GN instance types do not support EBS storage volumes.');
if (isSomeInstanceType('i3', 'r6gd', 'i4g', 'i4i', 'im4gn', 'r7gd') && ebsEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to refactor these instance type lists and store them in a named constant, to improve readability and maintenance. You could also use their human-friendlier InstanceClass names, something like:

private static readonly UNSUPPORTED_EBS = [
  ec2.InstanceClass.IO3,
  ec2.InstanceClass.MEMORY6_GRAVITON2_NVME_DRIVE,
  // ...
];

// ...
if(isSomeInstanceType(...UNSUPPORTED_EBS) && ebsEnabled) throw

You could also generate the error message using this list, without having to update them both manually:

function formatInstanceTypesList(instanceTypes: string[]): string {
  return instanceTypes.map((type) => type.toUpperCase()).join(', ').replace(/, ([^,]*)$/, ' and $1');
}

throw new Error(`${formatInstanceTypesList(UNSUPPORTED_EBS)} instance types do not support EBS storage volumes.`);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I took your suggestions into account and tried refactoring the relevant parts for this fix.
As for unrelated parts, I plan to refactor them in a separate PR.

Comment on lines 13 to 28
const domainProps: opensearch.DomainProps = {
removalPolicy: RemovalPolicy.DESTROY,
version: opensearch.EngineVersion.OPENSEARCH_2_17,
// specify the instance type that supports instance store
capacity: {
multiAzWithStandbyEnabled: false,
dataNodeInstanceType: instanceType,
dataNodes: 1,
},
// force ebs configuration to be disabled
ebs: {
enabled: false,
},
};

new opensearch.Domain(this, `Domain${index + 1}`, domainProps);
Copy link
Contributor

Choose a reason for hiding this comment

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

The domainProps variable seems unnecessary, especially because it has to be typed to get IDE hints instead of inheriting the constructor's signature

Suggested change
const domainProps: opensearch.DomainProps = {
removalPolicy: RemovalPolicy.DESTROY,
version: opensearch.EngineVersion.OPENSEARCH_2_17,
// specify the instance type that supports instance store
capacity: {
multiAzWithStandbyEnabled: false,
dataNodeInstanceType: instanceType,
dataNodes: 1,
},
// force ebs configuration to be disabled
ebs: {
enabled: false,
},
};
new opensearch.Domain(this, `Domain${index + 1}`, domainProps);
new opensearch.Domain(this, `Domain${index + 1}`, {
removalPolicy: RemovalPolicy.DESTROY,
version: opensearch.EngineVersion.OPENSEARCH_2_17,
// specify the instance type that supports instance store
capacity: {
multiAzWithStandbyEnabled: false,
dataNodeInstanceType: instanceType,
dataNodes: 1,
},
// force ebs configuration to be disabled
ebs: {
enabled: false,
},
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

];

const supportInstanceStorageInstanceType = [
ec2.InstanceClass.R3,
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'm not sure whether R3 should be included in unSupportEbsInstanceType because I couldn't find any documentation, and it has already been deprecated.

To avoid breaking changes, I decided to separate unSupportEbsInstanceType and supportInstanceStorageInstanceType in line with the current implementation, just in case.

Copy link
Contributor

Choose a reason for hiding this comment

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

You should still be able to deploy previous gen instances to test this, but it probably doesn't matter either way

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.86%. Comparing base (c879b5d) to head (508f00a).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32592   +/-   ##
=======================================
  Coverage   78.86%   78.86%           
=======================================
  Files         108      108           
  Lines        7165     7165           
  Branches     1319     1319           
=======================================
  Hits         5651     5651           
  Misses       1330     1330           
  Partials      184      184           
Flag Coverage Δ
suite.unit 78.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 78.86% <ø> (ø)

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mazyu36 mazyu36 requested a review from nmussy December 20, 2024 04:38
Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the refactor

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/small Small work item – less than a day of effort p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-opensearchservice/domain: r7gd not usable (aws_opensearchservice): i4i instances say they need EBS
3 participants