Skip to content

fix(appmesh): routes with weight 0 are assigned a weight of 1#21400

Merged
mergify[bot] merged 2 commits intoaws:mainfrom
zadjadr:main
Aug 1, 2022
Merged

fix(appmesh): routes with weight 0 are assigned a weight of 1#21400
mergify[bot] merged 2 commits intoaws:mainfrom
zadjadr:main

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 1, 2022


All Submissions:

fixes #21365

This PR fixes an unexpected behaivor when creating an appmesh.

Expected Behavior

Routes with targets of weight 0 should not change to 1 automatically.

Current Behavior (without fix)

Routes with targets of weight 0 are being changed to 1 automatically.

Solution

t.weight || 1 will result in 0 || 1 if the weight is set to 0. This will result in a route that can never have a weight of 0, since 0 is a faulty value.

To fix this, I compare the weight with undefined & return 1 only if the weight is undefined.

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Aug 1, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team August 1, 2022 06:48
@github-actions github-actions bot added the p2 label Aug 1, 2022
@ghost ghost changed the title fix(aws-appmesh): Allow route weight to be 0 (#21365) fix(aws-appmesh): allow route weight to be 0 (#21365) Aug 1, 2022
@ghost ghost changed the title fix(aws-appmesh): allow route weight to be 0 (#21365) fix(aws-appmesh): allow route weight to be 0 (fixes #21365) Aug 1, 2022
@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 and removed p2 labels Aug 1, 2022
Copy link
Copy Markdown
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Please make sure that your PR title confirms to the conventional commit standard (fix, feat, chore) and that it is written in a style that will reflect correctly in the change log (See Contributing Guide, Pull Requests).

Additionally, please make sure that your PR body describes the problem the PR is solving, and the design approach and alternatives considered. Explain why the PR solves the problem. A link to an issue is helpful, but does not replace an explanation of your thought process

renderedTargets.push({
virtualNode: t.virtualNode.virtualNodeName,
weight: t.weight || 1,
weight: t.weight == null ? 1 : t.weight,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You probably want to compare against undefined here instead of null.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done, thanks.

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review August 1, 2022 15:37

Pull request has been modified.

@ghost ghost changed the title fix(aws-appmesh): allow route weight to be 0 (fixes #21365) fix(aws-appmesh): allow route weight to be 0 Aug 1, 2022
@ghost ghost changed the title fix(aws-appmesh): allow route weight to be 0 fix(aws-appmesh): routes with weight 0 will be assigned a weight of 1 Aug 1, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the title fix(aws-appmesh): routes with weight 0 will be assigned a weight of 1 fix(appmesh): routes with weight 0 are assigned a weight of 1 Aug 1, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 1, 2022

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).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit fa0341f into aws:main Aug 1, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 1, 2022

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).

renderedTargets.push({
virtualNode: t.virtualNode.virtualNodeName,
weight: t.weight || 1,
weight: t.weight == undefined ? 1 : t.weight,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't this be 0?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree with @ytsssun This should be weight: t.weight || 0. Is there a reason we are defaulting to 1?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

0 would be a better default because The total weight for all targets combined must be less than or equal to 100. . But I wanted to keep this PR as small as possible without changing the established defaults.

It might be that changing this default could break something for some users. @TheRealAmazonKendra what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-appmesh): App Mesh Routes with a weight of 0 are being auto-assigned a weight of 1

4 participants