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(redshift): relocating a cluster #31993

Merged
merged 9 commits into from
Nov 12, 2024
Merged

Conversation

badmintoncryer
Copy link
Contributor

@badmintoncryer badmintoncryer commented Nov 2, 2024

Issue # (if applicable)

None

Reason for this change

AWS Redshift supports for configuring relocation a cluster and this feature is supported by cfn.

Description of changes

Add availabilityZoneRelocation to CusterProps.

Documents says that this feature is not supported for DC2 node type.

Relocation isn't supported on DC2 instance families of products.

However, this feature is only supported for RA3 node type in actual.

Example implementation:

new redshift.Cluster(stack, 'Cluster', {
  vpc: vpc,
  masterUser: {
    masterUsername: 'admin',
  },
  availabilityZoneRelocation: true,
  nodeType: redshift.NodeType.DC2_LARGE,
});

Result:

Failed resources:
AzRelocationClusterStack | 6:52:00 PM | CREATE_FAILED        | AWS::Redshift::Cluster                      | Cluster (ClusterEB0386A7) Resource handler returned message: "If the cluster node type isn?t RA3, availability zone relocation isn?t supported. (Service: Redshift, Status Code: 400, Request ID: 6382b593-cce5-4fe5-b4de-de1ad1c3a604)" (RequestToken: 94c999d9-7b72-19c4-9cfe-154fe6abc717, HandlerErrorCode: GeneralServiceException)

So I added this validation.

    if (props.availabilityZoneRelocation && !nodeType.startsWith('ra3')) {
      throw new Error(`Availability zone relocation is supported for only RA3 node types, got: ${props.nodeType}`);
    }

Description of how you validated changes

Add both unit and integ tests.

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team November 2, 2024 10:41
@github-actions github-actions bot added p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Nov 2, 2024
@badmintoncryer badmintoncryer marked this pull request as ready for review November 2, 2024 10:51
if (props.availabilityZoneRelocation && !nodeType.startsWith('ra3')) {
throw new Error(`Availability zone relocation is supported for only RA3 node types, got: ${props.nodeType}`);
}

this.cluster = new CfnCluster(this, 'Resource', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Ensure that user activity logging is enabled for the Redshift cluster. This feature logs each query before it is executed on the cluster's database. To activate this, associate a Redshift Cluster Parameter Group with the enable_user_activity_logging parameter set to true.

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 believe this feedback is inappropriate. This implementation is for existing L2 code, and to avoid breaking changes, we should not forcefully enable enable_user_activity_logging.

@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 Nov 2, 2024
Copy link
Contributor

@mazyu36 mazyu36 left a comment

Choose a reason for hiding this comment

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

Thanks. Just one question.


By using [relocation in Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-recovery.html), you allow Amazon Redshift to move a cluster to another Availability Zone (AZ) without any loss of data or changes to your applications.

To enable this feature, set the `availabilityZoneRelocation` property to `true` when creating the cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, relocation cannot be enabled after a cluster has been created?

It appears from the current README that relocation cannot be enabled after a cluster is created, but the documentation suggests that it should be possible to enable it post-creation.

https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-recovery.html#cluster-recovery-console

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right. I've updated description.

By using [relocation in Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-recovery.html), you allow Amazon Redshift to move a cluster to another Availability Zone (AZ) without any loss of data or changes to your applications.
This feature can be applied to both new and existing clusters.

To enable this feature, set the `availabilityZoneRelocation` property to `true`.

Copy link
Contributor

@mazyu36 mazyu36 left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM.

@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 Nov 4, 2024
@Leo10Gama Leo10Gama self-assigned this Nov 6, 2024
Copy link
Member

@Leo10Gama Leo10Gama left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Overall the changes look good, just one minor nit from me for an extra test.

To back your point about relocation only being on RA3 instance types, on top of the error message you encountered, it also seems like it's buried in the fourth paragraph of that documentation page:

Amazon Redshift cluster relocation is supported for the RA3 instance types only.

Leo10Gama
Leo10Gama previously approved these changes Nov 12, 2024
Copy link
Member

@Leo10Gama Leo10Gama left a comment

Choose a reason for hiding this comment

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

Thanks for the response, LGTM!

@Leo10Gama
Copy link
Member

@Mergifyio update

Copy link
Contributor

mergify bot commented Nov 12, 2024

update

❌ Mergify doesn't have permission to update

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/codecov.yml without workflows permission

@mergify mergify bot dismissed Leo10Gama’s stale review November 12, 2024 17:41

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 12, 2024
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.28%. Comparing base (338d4c2) to head (8ed6b6e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #31993   +/-   ##
=======================================
  Coverage   77.28%   77.28%           
=======================================
  Files         114      114           
  Lines        7628     7628           
  Branches     1360     1360           
=======================================
  Hits         5895     5895           
  Misses       1551     1551           
  Partials      182      182           
Flag Coverage Δ
suite.unit 77.28% <ø> (ø)

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

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Nov 12, 2024

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 b763d86 into aws:main Nov 12, 2024
22 checks passed
Copy link

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 Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants