-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
… 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
There was a problem hiding this 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[] = []; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
], | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Thanks for the thorough review, I do appreciate even the nitpicks :) |
@@ -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[]; |
There was a problem hiding this comment.
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;
).
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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?
There was a problem hiding this 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 🙂.
The build fails with
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 |
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? |
Ooops, yep. That's now fixed. |
There was a problem hiding this 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!
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). |
@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
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
…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*
…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*
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