Skip to content

feat(opensearchservice): nodeoptions for domain#32936

Merged
mergify[bot] merged 16 commits intoaws:mainfrom
sPredictorX1708:feature/opensearch-nodeoptions
Mar 3, 2025
Merged

feat(opensearchservice): nodeoptions for domain#32936
mergify[bot] merged 16 commits intoaws:mainfrom
sPredictorX1708:feature/opensearch-nodeoptions

Conversation

@sPredictorX1708
Copy link
Contributor

@sPredictorX1708 sPredictorX1708 commented Jan 15, 2025

Issue # (if applicable)

Closes #32553.

Reason for this change

#32553.

Recently as a part of coordinator node project we introduced a new parameter called NodeOptions, currently its part of L1 construct but we wanted it to be part of L2 construct and that is why raising this PR.

Description of changes

The code is very much similar to - #28497 and follows all standard practices in the repository.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Unit tests -

> yarn test aws-opensearchservice
yarn run v1.22.22
$ jest aws-opensearchservice
 PASS  aws-opensearchservice/test/log-group-resource-policy.test.ts
 PASS  aws-opensearchservice/test/opensearch-access-policy.test.ts
 PASS  aws-opensearchservice/test/domain.test.ts (5.687 s)

=============================== Coverage summary ===============================
Statements   : 43.87% ( 9437/21508 )
Branches     : 23.09% ( 2037/8820 )
Functions    : 25.62% ( 1229/4796 )
Lines        : 44.6% ( 9285/20816 )
================================================================================
Jest: "global" coverage threshold for statements (55%) not met: 43.87%
Jest: "global" coverage threshold for branches (35%) not met: 23.09%

Test Suites: 3 passed, 3 total
Tests:       1326 passed, 1326 total
Snapshots:   0 total
Time:        7.538 s

Integration Tests -

    Running in parallel across regions: us-east-1, us-east-2, us-west-2
    Running test /Users/dubesar/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.nodeoptions.js in us-east-1
      SUCCESS    aws-opensearchservice/test/integ.opensearch.nodeoptions-OpenSearchInteg/DefaultTest 658.125s
           NO ASSERTIONS
     
    Test Results: 
     
    Tests:    1 passed, 1 total
    ✨  Done in 659.62s.

Snapshots is also generated as a part of integration tests

Checklist

YES

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

### Reason for this change
Introduced new interfaces and validation for configuring coordinator nodes in OpenSearch domains, allowing users to specify node options such as instance type and count.

### Description of changes
- Added `NodeOptions` and `NodeConfig` interfaces to define configurations for coordinator nodes.
- Updated the `Domain` class to handle `nodeOptions` in the capacity configuration, including validation for instance type and count.
- Enhanced unit tests to cover new configurations and validation scenarios for coordinator nodes.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

*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 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Jan 15, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team January 15, 2025 13:05
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Jan 15, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review January 15, 2025 13:17

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@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 Jan 15, 2025
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

👍 Left some comments for adjustments

@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 Feb 22, 2025
Copy link
Member

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

Thank you for contributing, just a few clarifying questions.

/**
* Configuration for the node type
*/
readonly nodeConfig: NodeConfig;
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be a required property when the inner properties are all optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we rely on the backend to respond to this one? Meaning right now we have a logic on what is required.

eg - if enabled = true, then we need to pass type and count, if enabled = false, type and count become optional.

Will keep this logic as it as is for now.

Copy link
Member

@GavinZZ GavinZZ Mar 3, 2025

Choose a reason for hiding this comment

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

Not sure how this is related to the backend.

This is a pretty nit comment anyway: I'm mainly talking about the usage like below. Since the properties of NodeConfig are all optional, we can make nodeConfig an optional property as well so users are not limited to

{
  nodeType: someType,
  nodeConfig: {}
}

and can also simplify this to below

{
  nodeType: someType,
}

const coordinatorConfig = props.capacity.nodeOptions.find(opt => opt.nodeType === NodeType.COORDINATOR)?.nodeConfig;
if (coordinatorConfig?.enabled) {
const coordinatorType = initializeInstanceType(defaultCoordinatorInstanceType, coordinatorConfig.type);
if (!cdk.Token.isUnresolved(coordinatorType) && !coordinatorType.endsWith('.search')) {
Copy link
Member

Choose a reason for hiding this comment

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

is the unresolved token check needed as initializeInstanceType has done the check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Followed the same as it was for warm, data, master. Can you please check


if (props.capacity?.nodeOptions) {
// Validate coordinator node configuration
const coordinatorConfig = props.capacity.nodeOptions.find(opt => opt.nodeType === NodeType.COORDINATOR)?.nodeConfig;
Copy link
Member

Choose a reason for hiding this comment

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

I think find only returns the first matching item, what about the rest, are we going to do validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't have more than one nodeConfig object for a single node type

expect(metric.dimensions).toHaveProperty('DomainName');
}

each(testedOpenSearchVersions).test('can configure coordinator nodes with nodeOptions', (engineVersion) => {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a test case where we have two NodeOptions items and the second one is has invalid type that doesn't end with .search.

Copy link
Contributor Author

@sPredictorX1708 sPredictorX1708 Mar 3, 2025

Choose a reason for hiding this comment

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

We can't have two nodeoptions of same node type. The backend have checks for that and will throw error.

@GavinZZ GavinZZ self-assigned this Feb 26, 2025
@sPredictorX1708 sPredictorX1708 requested a review from GavinZZ March 3, 2025 08:26
GavinZZ
GavinZZ previously approved these changes Mar 3, 2025
@mergify
Copy link
Contributor

mergify bot commented Mar 3, 2025

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
Copy link
Contributor

mergify bot commented Mar 3, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@codecov
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.21%. Comparing base (97744e7) to head (d44a542).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32936   +/-   ##
=======================================
  Coverage   82.21%   82.21%           
=======================================
  Files         119      119           
  Lines        6876     6876           
  Branches     1162     1162           
=======================================
  Hits         5653     5653           
  Misses       1120     1120           
  Partials      103      103           
Flag Coverage Δ
suite.unit 82.21% <ø> (ø)

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

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.21% <ø> (ø)

@mergify mergify bot dismissed GavinZZ’s stale review March 3, 2025 22:45

Pull request has been modified.

@sPredictorX1708 sPredictorX1708 requested a review from GavinZZ March 3, 2025 22:54
@mergify
Copy link
Contributor

mergify bot commented Mar 3, 2025

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: 33499c7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Mar 3, 2025

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 merged commit 1b6f0c3 into aws:main Mar 3, 2025
10 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day 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.

Amazon OpenSearch Service: High Level Constructs For OpenSearch Coordinator (NodeOptions) Feature

5 participants