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(rds): introduce type-safe engine versions #9016

Merged
merged 1 commit into from
Jul 16, 2020

Conversation

skinny85
Copy link
Contributor

@skinny85 skinny85 commented Jul 11, 2020

Change engine versions, for boh cluster and instance engines,
from strings to strongly-typed classes with static constants representing common versions.

Fixes #6532

BREAKING CHANGE: the property 'version' has been changed from string to an engine-specific
version class; use VersionClass.of() if you need to create a specific version of an engine from a string

  • rds: the property ParameterGroupProps.family has been renamed to engine, and its type changed from string to IEngine
  • rds: the property engineVersion in IClusterEngine changed from a string to EngineVersion
  • rds: the property engineVersion in IInstanceEngine changed from a string to EngineVersion
  • rds: the property parameterGroupFamily in IClusterEngine changed from required to optional
  • rds: the property parameterGroupFamily in IInstanceEngine changed from required to optional

@skinny85 skinny85 self-assigned this Jul 11, 2020
@skinny85
Copy link
Contributor Author

skinny85 commented Jul 11, 2020

Still missing:

  • ReadMe changes

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 11, 2020
Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

With this pattern, is there any equivalent of specifying major version, but leaving the minor version to latest/recommended? For example, can I say: "create an Aurora cluster with v2" or "MySQL 5.7" and let the CDK figure out the details?

packages/@aws-cdk/aws-rds/lib/cluster-engine.ts Outdated Show resolved Hide resolved
@skinny85
Copy link
Contributor Author

With this pattern, is there any equivalent of specifying major version, but leaving the minor version to latest/recommended? For example, can I say: "create an Aurora cluster with v2" or "MySQL 5.7" and let the CDK figure out the details?

Not currently, but I really like the idea!

What API would you see for this? Something like AuroraEngineVersion.latest(majorVersion: string)?

@skinny85
Copy link
Contributor Author

cc @jogold if you'd like to weigh in here, I would love to use your expertise!

@skinny85 skinny85 added the pr/do-not-merge This PR should not be merged at this time. label Jul 15, 2020
@skinny85
Copy link
Contributor Author

With this pattern, is there any equivalent of specifying major version, but leaving the minor version to latest/recommended? For example, can I say: "create an Aurora cluster with v2" or "MySQL 5.7" and let the CDK figure out the details?

Not currently, but I really like the idea!

What API would you see for this? Something like AuroraEngineVersion.latest(majorVersion: string)?

Done for the instance engines (unfortunately, there is no such option for cluster engines, at least that I know of).

@skinny85
Copy link
Contributor Author

skinny85 commented Jul 15, 2020

@njlynch @shivlaks @jogold this is ready for another round of reviews. I also have one open question, that I want your opinion on.

I wonder what should be the behavior for engines without a version specified, with respect to their parameterGroupFamily used in ParameterGroup and majorVersion used in OptionGroup. Today, for the engines that don't a version specified (so, the static constants from DatabaseClusterEngine and DatabaseInstanceEngine), they have a well-defined "default" majorVersion (and, by extension, parameterGroupFamily, as that is equal to <engine-type><major-version>). In this PR, I preserved this behavior, but I'm having second thoughts about this now.

For example, let's take the DatabaseInstanceEngine.POSTGRES constant. It uses 11 as its default major version. But there is already version 12 supported by RDS. Does it mean, at some point, that creating a postgres engine without a version will start using major version 12, instead of 11? At that point, will all of the ParameterGroups and OptionGroups created with 11 be invalid? It seems like a pretty risky thing to do.

I wonder if we should guard customers from this potential mistake, and simply say that engines without a version don't have a majorVersion defined, and thus cannot be used as arguments when creating ParameterGroup and OptionGroup. It would be a breaking change, of course, but maybe it's the right thing to do, considering how dangerous this functionality might be?

I would love to hear your thoughts!

@skinny85 skinny85 requested a review from njlynch July 15, 2020 02:07
*/
export class OracleEngineVersion {
/** Version "11.2" (only a major version, without a specific minor version). */
public static readonly VER_11_2 = OracleEngineVersion.of('11.2', '11.2');
Copy link
Contributor

Choose a reason for hiding this comment

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

https://forums.aws.amazon.com/ann.jspa?annID=7341

Amazon RDS for Oracle will end the support for Oracle Database version 11.2.0.4 Standard Edition 1 (SE1) for license-included (LI) on October 31, 2020. For bring-your-own-license (BYOL), RDS for Oracle will end the support for Oracle Database version 11.2.0.4 for all editions on December 31, 2020.

Starting on August 1, 2020, Amazon RDS for Oracle will disable the ability to create new DB instances using 11.2.0.4 on SE1 with LI.

You can drop all the VER_11_xxx (and the ORACLE_SE and ORACLE_SE1 because they only allow v11 instances).

This also means that for Oracle you maybe need specific versions lists per engine (ee, se2).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. The way I did it, is I split the existing one class into 2. OracleLegacyEngineVersion and OracleEngineVersion. The first one has all of the 11.2 versions, and is used in oracleSe and oracleSe1 methods. The other one has all version 12.1 and up, and is used for oracleSe2 and oracleEe methods.

Let me know if this makes sense @jogold !

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good.

packages/@aws-cdk/aws-rds/README.md Show resolved Hide resolved
@jogold
Copy link
Contributor

jogold commented Jul 15, 2020

I wonder what should be the behavior for engines without a version specified

I personally think that the CDK should not let users create an instance/cluster without specifying a version. Making the version required will force users to think about it vs forget to specify it by mistake with potentially bad consequences (+ RDS deploy times are really long so this mistake can take hours to notice/fix).

A RDS instance/cluster is a costly piece of cloud infrastructure (and a complex one) and users (usually experienced ones) creating those instances/clusters should be forced to "design" before deploy.

@shivlaks
Copy link
Contributor

For example, let's take the DatabaseInstanceEngine.POSTGRES constant. It uses 11 as its default major version. But there is already version 12 supported by RDS. Does it mean, at some point, that creating a postgres engine without a version will start using major version 12, instead of 11? At that point, will all of the ParameterGroups and OptionGroups created with 11 be invalid? It seems like a pretty risky thing to do.

@skinny85 - I also share your concern for the versioning. In this example, if version 12 is supported, is it available in all regions at the same time? upgrading their CDK app would also switch out the version underneath the customer.

We had a similar problem in stepfunctions-tasks where Fargate has a "LATEST" which currently points to 1.3 and 1.4 has been out for a little bit now. It will presumably change to 1.4 at some point. To be safe, we ended up making the platform version required with the understanding that we can relax the condition and make it optional in the future if we decide there's a sensible default that doesn't hide a future problem.

I'd be inclined to go towards making it required for now and relaxing that condition at a later time (if it makes sense to).
@jogold also makes some good points around cost, deployment time, remediation time(s).

@skinny85
Copy link
Contributor Author

skinny85 commented Jul 16, 2020

I wonder what should be the behavior for engines without a version specified

I personally think that the CDK should not let users create an instance/cluster without specifying a version. Making the version required will force users to think about it vs forget to specify it by mistake with potentially bad consequences (+ RDS deploy times are really long so this mistake can take hours to notice/fix).

A RDS instance/cluster is a costly piece of cloud infrastructure (and a complex one) and users (usually experienced ones) creating those instances/clusters should be forced to "design" before deploy.

For example, let's take the DatabaseInstanceEngine.POSTGRES constant. It uses 11 as its default major version. But there is already version 12 supported by RDS. Does it mean, at some point, that creating a postgres engine without a version will start using major version 12, instead of 11? At that point, will all of the ParameterGroups and OptionGroups created with 11 be invalid? It seems like a pretty risky thing to do.

@skinny85 - I also share your concern for the versioning. In this example, if version 12 is supported, is it available in all regions at the same time? upgrading their CDK app would also switch out the version underneath the customer.

We had a similar problem in stepfunctions-tasks where Fargate has a "LATEST" which currently points to 1.3 and 1.4 has been out for a little bit now. It will presumably change to 1.4 at some point. To be safe, we ended up making the platform version required with the understanding that we can relax the condition and make it optional in the future if we decide there's a sensible default that doesn't hide a future problem.

I'd be inclined to go towards making it required for now and relaxing that condition at a later time (if it makes sense to).
@jogold also makes some good points around cost, deployment time, remediation time(s).

OK. How about this?

  1. Let's deprecate the current unversioned constants in DatabaseClusterEngine and InstanceClusterEngine, saying using them is not recommended. I feel like outright banning unversioned Clusters and Instances is a little too harsh.
  2. Let's make version required in all static engine construction methods.
  3. Let's remove the capability of the unversioned engines to have a default majorVersion (and thus a parameterGroupFamily). So, it will not be possible to use them for ParameterGroup and OptionGroup. EDIT: with the exception of Aurora and AuroraMysql, who always have majorVersion 5.6 and 5.7, respectively.

How does this sound @jogold @shivlaks ?

@skinny85
Copy link
Contributor Author

@njlynch @shivlaks @jogold I've implemented the discussed changes - this is ready for another round of reviews!

@skinny85 skinny85 requested a review from shivlaks July 16, 2020 02:47
@jogold
Copy link
Contributor

jogold commented Jul 16, 2020

OK. How about this?

  1. Let's deprecate the current unversioned constants in DatabaseClusterEngine and InstanceClusterEngine, saying using them is not recommended. I feel like outright banning unversioned Clusters and Instances is a little too harsh.
  2. Let's make version required in all static engine construction methods.
  3. Let's remove the capability of the unversioned engines to have a default majorVersion (and thus a parameterGroupFamily). So, it will not be possible to use them for ParameterGroup and OptionGroup. EDIT: with the exception of Aurora and AuroraMysql, who always have majorVersion 5.6 and 5.7, respectively.

How does this sound @jogold @shivlaks ?

Sounds good!

Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

Generally looks good to me - would want @shivlaks and/or @jogold to take another pass as well, since they've had more feedback than me.

* The versions for the legacy Oracle instance engines
* (those returned by {@link DatabaseInstanceEngine.oracleSe}
* and {@link DatabaseInstanceEngine.oracleSe1}).
* Note: RDS will stop allowing creating new databases with this version in August 2020.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth pushing this only to deprecate it in one month?

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 think so. People still might have CDK code with existing databases using it.

Copy link
Contributor

Choose a reason for hiding this comment

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

They can use the of() then?

packages/@aws-cdk/aws-rds/lib/instance-engine.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/lib/instance-engine.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

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

I'm good with these changes. thanks for keeping with it and getting it here!!!

@skinny85 skinny85 removed the pr/do-not-merge This PR should not be merged at this time. label Jul 16, 2020
@skinny85 skinny85 added the pr/do-not-merge This PR should not be merged at this time. label Jul 16, 2020
engine: rds.DatabaseInstanceEngine.oracleSe1({
version: '11.2',
}),
engine: rds.DatabaseInstanceEngine.ORACLE_SE1,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should change to SE2 here also because this integ test will soon not deploy anymore, the instance should also be updated.

Copy link
Contributor Author

@skinny85 skinny85 Jul 16, 2020

Choose a reason for hiding this comment

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

You're right. I'll do that in a follow-up PR (probably when we deprecate oracleSe and oracleSe1).

@skinny85 skinny85 removed the pr/do-not-merge This PR should not be merged at this time. label Jul 16, 2020
Change engine versions, for boh cluster and instance engines,
from strings to strongly-typed classes with static constants representing common versions.

Fixes aws#6532

BREAKING CHANGE: the property 'version' has been changed from string to an engine-specific
  version class; use VersionClass.of() if you need to create a specific version of an engine from a string
* **rds**: the property engineVersion in IClusterEngine changed from a string to EngineVersion
* **rds**: the property engineVersion in IInstanceEngine changed from a string to EngineVersion
* **rds**: the property parameterGroupFamily in IClusterEngine changed from required to optional
* **rds**: the property parameterGroupFamily in IInstanceEngine changed from required to optional
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 9eddbca
  • 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 Jul 16, 2020

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 fab7e28 into aws:master Jul 16, 2020
@skinny85 skinny85 deleted the feat/rds-engine-versions branch July 16, 2020 20:08
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this pull request Aug 11, 2020
Change engine versions, for boh cluster and instance engines,
from strings to strongly-typed classes with static constants representing common versions.

Fixes aws#6532

BREAKING CHANGE: the property 'version' has been changed from string to an engine-specific
  version class; use VersionClass.of() if you need to create a specific version of an engine from a string
* **rds**: the property ParameterGroupProps.family has been renamed to engine, and its type changed from string to IEngine
* **rds**: the property engineVersion in IClusterEngine changed from a string to EngineVersion
* **rds**: the property engineVersion in IInstanceEngine changed from a string to EngineVersion
* **rds**: the property parameterGroupFamily in IClusterEngine changed from required to optional
* **rds**: the property parameterGroupFamily in IInstanceEngine changed from required to optional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better type database engine versions
5 participants