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(aws-cdk): cdk diff always fails on diff #17862

Merged
merged 3 commits into from
Dec 6, 2021

Conversation

njlynch
Copy link
Contributor

@njlynch njlynch commented Dec 6, 2021

In v1, the original behavior was that cdk diff exited 0 on a clean diff (no
changes), and exited 1 on changes. #4721 introduced a new feature flag to always
have cdk diff exit 0. As is standard, the "default" for the flag was false,
but the future behavior was true, meaning any new CDK project created after
that release (v1.19.0) defaulted to always exiting 0.

In v2, the feature flag was expired, meaning users could no longer set
it. Typically, the behavior (FeatureFlags.isEnabled) checks and errors if an
expired flag is explicitly set, and always returns true for expired flags
otherwise. However, the CDK CLI helper function did not contain this
functionality. That means for current v2 projects, the v1-ported default value
is used (false). This means cdk diff always exits 1 when there's a diff, and
there's no way for a user to disable this behavior.

This change updates the CLI behavior to default to true for expired flags, same
as any other feature flag check; this means cdk diff will return to exiting 0,
as v1 apps have been doing for years. The FeatureFlags.isEnabled method can't
be used, as it requires a Construct node.

I also took the liberty of explicitly setting the "default" to true for all
expired flags, so any other direct access of the flag (not using the FeatureFlag
library) will have the same consistent behavior.

fixes #17832


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

@njlynch njlynch requested a review from a team December 6, 2021 12:54
@njlynch njlynch self-assigned this Dec 6, 2021
@gitpod-io
Copy link

gitpod-io bot commented Dec 6, 2021

@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Dec 6, 2021
@njlynch njlynch changed the title fix: cdk diff always fails on diff fix(aws-cdk): cdk diff always fails on diff Dec 6, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 6, 2021
In v1, the original behavior was that `cdk diff` exited 0 on a clean diff (no
changes), and exited 1 on changes. #4721 introduced a new feature flag to always
have `cdk diff` exit 0. As is standard, the "default" for the flag was `false`,
but the future behavior was `true`, meaning any new CDK project created after
that release (v1.19.0) defaulted to always exiting 0.

In v2, the feature flag was expired, meaning users could no longer set
it. Typically, the behavior (`FeatureFlags.isEnabled`) checks and errors if an
expired flag is explicitly set, and always returns true for expired flags
otherwise. However, the CDK CLI helper function did not contain this
functionality. That means for current v2 projects, the v1-ported default value
is used (false). This means `cdk diff` *always* exits 1 when there's a diff, and
there's no way for a user to disable this behavior.

This change updates the CLI behavior to default to true for expired flags, same
as any other feature flag check; this means `cdk diff` will return to exiting 0,
as v1 apps have been doing for years. The `FeatureFlags.isEnabled` method can't
be used, as it requires a Construct node.

I also took the liberty of explicitly setting the "default" to true for all
expired flags, so any other direct access of the flag (not using the FeatureFlag
library) will have the same consistent behavior.
@njlynch njlynch force-pushed the njlynch/v2-feature-flag-fixup branch from 4290607 to 840d8f3 Compare December 6, 2021 12:59
@njlynch njlynch added pr-linter/exempt-test The PR linter will not require test changes pr/do-not-merge This PR should not be merged at this time. labels Dec 6, 2021
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@njlynch njlynch removed the pr/do-not-merge This PR should not be merged at this time. label Dec 6, 2021
@njlynch njlynch merged commit 6bb4a46 into v2-main Dec 6, 2021
@njlynch njlynch deleted the njlynch/v2-feature-flag-fixup branch December 6, 2021 16:01
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. package/tools Related to AWS CDK Tools or CLI pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants