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(rds): instance identifiers and endpoints of a Cluster are blank #14394

Merged
merged 12 commits into from Apr 29, 2021

Conversation

vilikin
Copy link
Contributor

@vilikin vilikin commented Apr 27, 2021

Previously instanceIdentifiers and instanceEndpoints were readonly properties of DatabaseClusterNew, defaulting to empty arrays. However, they they were never set to the correct values after instances were added to the cluster. Those properties are now moved on to the DatabaseCluster and DatabaseClusterFromSnapshot classes where they can now actually be set to correct values.

fixes #14377


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

… cluster

Previously instanceIdentifiers and instanceEndpoints were readonly properties
of DatabaseClusterNew, defaulting to empty arrays. However, they they were
never set to the correct values after instances were added to the cluster.
Those properties are now moved on to the DatabaseCluster and
DatabaseClusterFromSnapshot classes where they can now actually be set to
correct values.

fixes aws#14377
@gitpod-io
Copy link

gitpod-io bot commented Apr 27, 2021

@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Apr 27, 2021
Copy link
Contributor

@skinny85 skinny85 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 @vilikin! It looks great. However, since I'm a picky asshole, I've managed to find a few places I would do things differently. I hope you agree with my suggestions!

@@ -290,8 +290,6 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
* Never undefined.
*/
public readonly engine?: IClusterEngine;
public readonly instanceIdentifiers: string[] = [];
public readonly instanceEndpoints: Endpoint[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why move these? We keep members in a specific order (public, then protected, then private). Let's keep it this way here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are actually moved to the implementing classes, so they no longer exist on the DatabaseClusterNew class. (diff looks almost as if they were just moved a bit down inside same class, but there's actually 200 rows in between)

The reason for moving them was that I could not figure out a way to keep them readonly on the base class if we needed to set them from the implementing classes.

packages/@aws-cdk/aws-rds/lib/cluster.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/lib/cluster.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/lib/cluster.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/lib/cluster.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/lib/cluster.ts Outdated Show resolved Hide resolved
],
},
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This is such a small change, I'm not sure it warrants an entirely separate unit test.

How about adding a new assertion to existing tests?

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 now included the expectations to an existing unit test that was creating a cluster with 1 db instance.

But I do feel like the existing unit tests have been pretty specific on testing just a certain functionality, so it didn't fit too naturally into any existing test in my opinion.

@mergify mergify bot dismissed skinny85’s stale review April 28, 2021 08:10

Pull request has been modified.

@vilikin
Copy link
Contributor Author

vilikin commented Apr 28, 2021

Thanks for the contribution @vilikin! It looks great. However, since I'm a picky asshole, I've managed to find a few places I would do things differently. I hope you agree with my suggestions!

Thanks for the thorough review, I do appreciate even the nitpicks :)

packages/@aws-cdk/aws-rds/test/cluster.test.ts Outdated Show resolved Hide resolved
@@ -484,6 +482,9 @@ export class DatabaseCluster extends DatabaseClusterNew {
private readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication;
private readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication;

public readonly instanceIdentifiers: string[];
public readonly instanceEndpoints: Endpoint[];
Copy link
Contributor

Choose a reason for hiding this comment

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

They are actually moved to the implementing classes, so they no longer exist on the DatabaseClusterNew class. (diff looks almost as if they were just moved a bit down inside same class, but there's actually 200 rows in between)

The reason for moving them was that I could not figure out a way to keep them readonly on the base class if we needed to set them from the implementing classes.

Ah, right. I missed that. Sounds good!

Can you please move these to the block of the public fields above? (The one that ends with public readonly connections: ec2.Connections;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, forgot to address that part of the comment. Now it should be ok :)

@mergify mergify bot dismissed skinny85’s stale review April 29, 2021 04:57

Pull request has been modified.

@vilikin vilikin requested a review from skinny85 April 29, 2021 04:58
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

2 small things are still not perfect - any chance of getting these in @vilikin?

packages/@aws-cdk/aws-rds/lib/cluster.ts Outdated Show resolved Hide resolved
@vilikin vilikin requested a review from skinny85 April 29, 2021 18:11
skinny85
skinny85 previously approved these changes Apr 29, 2021
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Awesome contribution. Thanks for enduring my pickiness @vilikin 🙂.

@skinny85
Copy link
Contributor

The build fails with

@aws-cdk/aws-rds: FAIL test/cluster.test.js (14.981 s)
@aws-cdk/aws-rds:   � cluster › create a cluster from a snapshot
@aws-cdk/aws-rds:     expect(received).toContain(expected) // indexOf
@aws-cdk/aws-rds:     Expected value:  {"Ref": "DatabaseInstance1844F58FD"}
@aws-cdk/aws-rds:     Received object: {"Ref": "DatabaseInstance1844F58FD"}

I think this

    expect(stack.resolve(cluster.instanceIdentifiers[0])).toContain({
      Ref: 'DatabaseInstance1844F58FD',
    });

should be

    expect(stack.resolve(cluster.instanceIdentifiers[0])).toEqual({
      Ref: 'DatabaseInstance1844F58FD',
    });

As in the test for DatabaseCluster.

@mergify mergify bot dismissed skinny85’s stale review April 29, 2021 18:37

Pull request has been modified.

@vilikin
Copy link
Contributor Author

vilikin commented Apr 29, 2021

Awesome contribution. Thanks for enduring my pickiness @vilikin 🙂.

Thanks for all the comments, they were all very much valid. I was just a bit careless due to lack of time. (which I obviously then spent more in the end... :D)

Is this now just going to be auto-merged at some point or is there still something to do?

@vilikin
Copy link
Contributor Author

vilikin commented Apr 29, 2021

The build fails with

@aws-cdk/aws-rds: FAIL test/cluster.test.js (14.981 s)
@aws-cdk/aws-rds:   � cluster › create a cluster from a snapshot
@aws-cdk/aws-rds:     expect(received).toContain(expected) // indexOf
@aws-cdk/aws-rds:     Expected value:  {"Ref": "DatabaseInstance1844F58FD"}
@aws-cdk/aws-rds:     Received object: {"Ref": "DatabaseInstance1844F58FD"}

I think this

    expect(stack.resolve(cluster.instanceIdentifiers[0])).toContain({
      Ref: 'DatabaseInstance1844F58FD',
    });

should be

    expect(stack.resolve(cluster.instanceIdentifiers[0])).toEqual({
      Ref: 'DatabaseInstance1844F58FD',
    });

As in the test for DatabaseCluster.

Ooops, yep. That's now fixed.

@skinny85 skinny85 changed the title fix(aws-rds): allow accessing instance identifiers and endpoints of a cluster fix(rds): instance identifiers and endpoints of a Cluster are unset Apr 29, 2021
skinny85
skinny85 previously approved these changes Apr 29, 2021
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

The build fails with

@aws-cdk/aws-rds: FAIL test/cluster.test.js (14.981 s)
@aws-cdk/aws-rds:   � cluster › create a cluster from a snapshot
@aws-cdk/aws-rds:     expect(received).toContain(expected) // indexOf
@aws-cdk/aws-rds:     Expected value:  {"Ref": "DatabaseInstance1844F58FD"}
@aws-cdk/aws-rds:     Received object: {"Ref": "DatabaseInstance1844F58FD"}

I think this

    expect(stack.resolve(cluster.instanceIdentifiers[0])).toContain({
      Ref: 'DatabaseInstance1844F58FD',
    });

should be

    expect(stack.resolve(cluster.instanceIdentifiers[0])).toEqual({
      Ref: 'DatabaseInstance1844F58FD',
    });

As in the test for DatabaseCluster.

Ooops, yep. That's now fixed.

Awesome, thanks so much!

@mergify
Copy link
Contributor

mergify bot commented Apr 29, 2021

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

@skinny85
Copy link
Contributor

@vilikin looks like there's a merge conflict with the current master. Do you have time to resolve it?

@vilikin
Copy link
Contributor Author

vilikin commented Apr 29, 2021

@vilikin looks like there's a merge conflict with the current master. Do you have time to resolve it?

Actually, this time I really don't have time anymore. We are expecting a baby and the water just broke, so we are off to the hospital soon - so if you'd be able to resolve it, I would highly appreciate it. :D

@skinny85
Copy link
Contributor

@vilikin looks like there's a merge conflict with the current master. Do you have time to resolve it?

Actually, this time I really don't have time anymore. We are expecting a baby and the water just broke, so we are off to the hospital soon - so if you'd be able to resolve it, I would highly appreciate it. :D

That is a great excuse for not resolving merge conflicts. I'll handle this one. Best of luck with the baby!

# Conflicts:
#	packages/@aws-cdk/aws-rds/test/cluster.test.ts
@mergify mergify bot dismissed skinny85’s stale review April 29, 2021 19:14

Pull request has been modified.

@skinny85 skinny85 changed the title fix(rds): instance identifiers and endpoints of a Cluster are unset fix(rds): instance identifiers and endpoints of a Cluster are blank Apr 29, 2021
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: d46c481
  • 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 Apr 29, 2021

Thank you for contributing! Your pull request will be updated from master 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 9597d97 into aws:master Apr 29, 2021
john-tipper pushed a commit to john-tipper/aws-cdk that referenced this pull request May 10, 2021
…ws#14394)

Previously instanceIdentifiers and instanceEndpoints were readonly properties of DatabaseClusterNew, defaulting to empty arrays. However, they they were never set to the correct values after instances were added to the cluster. Those properties are now moved on to the DatabaseCluster and DatabaseClusterFromSnapshot classes where they can now actually be set to correct values.

fixes aws#14377


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
…ws#14394)

Previously instanceIdentifiers and instanceEndpoints were readonly properties of DatabaseClusterNew, defaulting to empty arrays. However, they they were never set to the correct values after instances were added to the cluster. Those properties are now moved on to the DatabaseCluster and DatabaseClusterFromSnapshot classes where they can now actually be set to correct values.

fixes aws#14377


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-rds: instance identifiers and endpoints not available on DatabaseCluster
3 participants