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(eks): changing the subnets or securityGroupIds order causes an error #24163

Merged
merged 4 commits into from
Feb 22, 2023

Conversation

AviorSchreiber
Copy link
Contributor

@AviorSchreiber AviorSchreiber commented Feb 14, 2023

When the subnet list is passed to the EKS Cluster construct in a different order, an update is triggered to the EKS cluster.
The update process fails as it falsely identifies a change for an unsupported update, although the list has the same items.

The solution is to change the analyzeUpdate function to return updateVpc: false if only the securityGroups/subnetsId order has been changed.

Fixes: #24162


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

@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Feb 14, 2023
@gitpod-io
Copy link

gitpod-io bot commented Feb 14, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team February 14, 2023 11:13
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@AviorSchreiber
Copy link
Contributor Author

Clarification Request

How can I perform integration test for that change?
it only happens when updating the stack

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 14, 2023
@aws-cdk-automation aws-cdk-automation removed the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 14, 2023
@Naumel
Copy link
Contributor

Naumel commented Feb 15, 2023

Clarification Request

How can I perform integration test for that change? it only happens when updating the stack

Hi, have you looked at the information present in https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md already?

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 15, 2023
@AviorSchreiber
Copy link
Contributor Author

Clarification Request
How can I perform integration test for that change? it only happens when updating the stack

Hi, have you looked at the information present in https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md already?

@Naumel
I have read the guide and look over the current examples.
I don't see how can I perform an integration test that checks an event that only occurs on stack update.
The way I see it, the test must have a stack deployed and then updated, in order to evaluate whether the subnets have changed or not.
This is not something that can be determined by simply synthesizing the stack.
I think that it might be a case where we cannot write an integration test.

Any ideas?

@TheRealAmazonKendra
Copy link
Contributor

Clarification Request
How can I perform integration test for that change? it only happens when updating the stack

Hi, have you looked at the information present in https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md already?

@Naumel I have read the guide and look over the current examples. I don't see how can I perform an integration test that checks an event that only occurs on stack update. The way I see it, the test must have a stack deployed and then updated, in order to evaluate whether the subnets have changed or not. This is not something that can be determined by simply synthesizing the stack. I think that it might be a case where we cannot write an integration test.

Any ideas?

Ah, actually this is a really good question because we don't have a function specifically for update operations. We can, however, edit one of these fields on an existing test because then it deploys the original template first, and then performs the update on it as long as you use the flag --update-on-failed. Can you do that one a test and commit the change? We'll call that good.

@TheRealAmazonKendra TheRealAmazonKendra removed the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 17, 2023
@TheRealAmazonKendra
Copy link
Contributor

Removing the label for now but please feel free to add it back (using the same phrase in a comment) if you need more information or further clarification.

@aws-cdk-automation aws-cdk-automation dismissed their stale review February 19, 2023 15:42

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

@AviorSchreiber
Copy link
Contributor Author

Clarification Request
How can I perform integration test for that change? it only happens when updating the stack

Hi, have you looked at the information present in https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md already?

@Naumel I have read the guide and look over the current examples. I don't see how can I perform an integration test that checks an event that only occurs on stack update. The way I see it, the test must have a stack deployed and then updated, in order to evaluate whether the subnets have changed or not. This is not something that can be determined by simply synthesizing the stack. I think that it might be a case where we cannot write an integration test.
Any ideas?

Ah, actually this is a really good question because we don't have a function specifically for update operations. We can, however, edit one of these fields on an existing test because then it deploys the original template first, and then performs the update on it as long as you use the flag --update-on-failed. Can you do that one a test and commit the change? We'll call that good.

@TheRealAmazonKendra can you please review it now?

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 19, 2023
@TheRealAmazonKendra TheRealAmazonKendra removed the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 20, 2023
@TheRealAmazonKendra
Copy link
Contributor

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 (See Contributing Guide, Pull Requests)

@TheRealAmazonKendra
Copy link
Contributor

Here is my concern about this change, and perhaps you can provide clarity on whether or not this will be a problem, by using sort, won't this cause the error this was meant to solve on existing an existing EKS cluster? I'm going to pull this PR down to test a couple scenarios, but this change may need to go under a feature flag. I'll provide a follow up later today.

@AviorSchreiber
Copy link
Contributor Author

Here is my concern about this change, and perhaps you can provide clarity on whether or not this will be a problem, by using sort, won't this cause the error this was meant to solve on existing an existing EKS cluster? I'm going to pull this PR down to test a couple scenarios, but this change may need to go under a feature flag. I'll provide a follow up later today.

It won't cause an existing cluster to be failed and I'll explain why.

The change is analyzed by a lambda function that returns for each component if it changed or not.
The bug occurs due to the comparison mechanism, which takes into account the order of the list items and not just the list contents.

The expected behavior is not to consider the order of the list but the Subnets IDs only.

So if we compare the sorted subnets that passed to the function, new ones and old we will get the same object if the new subnets IDs are not changed.

@TheRealAmazonKendra
Copy link
Contributor

Here is my concern about this change, and perhaps you can provide clarity on whether or not this will be a problem, by using sort, won't this cause the error this was meant to solve on existing an existing EKS cluster? I'm going to pull this PR down to test a couple scenarios, but this change may need to go under a feature flag. I'll provide a follow up later today.

It won't cause an existing cluster to be failed and I'll explain why.

The change is analyzed by a lambda function that returns for each component if it changed or not. The bug occurs due to the comparison mechanism, which takes into account the order of the list items and not just the list contents.

The expected behavior is not to consider the order of the list but the Subnets IDs only.

So if we compare the sorted subnets that passed to the function, new ones and old we will get the same object if the new subnets IDs are not changed.

Oh, wonderful! Thank you for clarifying!

@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Feb 21, 2023

update

❌ Base branch update has failed

refusing to allow a GitHub App to create or update workflow .github/workflows/yarn-upgrade-v1main.yml without workflows permission
err-code: 5AF07

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
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.

Approving as long as the build succeeds.

@TheRealAmazonKendra
Copy link
Contributor

Oh, it already did. Great!

@mergify
Copy link
Contributor

mergify bot commented Feb 22, 2023

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

@mergify mergify bot merged commit 09c2c19 into aws:main Feb 22, 2023
Naumel pushed a commit that referenced this pull request Feb 24, 2023
…ror (#24163)

When the subnet list is passed to the EKS Cluster construct in a different order, an update is triggered to the EKS cluster. 
The update process fails as it falsely identifies a change for an unsupported update, although the list has the same items.

The solution is to change the analyzeUpdate function to return `updateVpc: false` if only the securityGroups/subnetsId order has been changed. 


Fixes: [#24162](#24162)

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
beck3905 pushed a commit to beck3905/aws-cdk that referenced this pull request Feb 28, 2023
…ror (aws#24163)

When the subnet list is passed to the EKS Cluster construct in a different order, an update is triggered to the EKS cluster. 
The update process fails as it falsely identifies a change for an unsupported update, although the list has the same items.

The solution is to change the analyzeUpdate function to return `updateVpc: false` if only the securityGroups/subnetsId order has been changed. 


Fixes: [aws#24162](aws#24162)

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Mar 13, 2023
…ror (aws#24163)

When the subnet list is passed to the EKS Cluster construct in a different order, an update is triggered to the EKS cluster. 
The update process fails as it falsely identifies a change for an unsupported update, although the list has the same items.

The solution is to change the analyzeUpdate function to return `updateVpc: false` if only the securityGroups/subnetsId order has been changed. 


Fixes: [aws#24162](aws#24162)

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Mar 28, 2023
…ror (aws#24163)

When the subnet list is passed to the EKS Cluster construct in a different order, an update is triggered to the EKS cluster. 
The update process fails as it falsely identifies a change for an unsupported update, although the list has the same items.

The solution is to change the analyzeUpdate function to return `updateVpc: false` if only the securityGroups/subnetsId order has been changed. 


Fixes: [aws#24162](aws#24162)

---
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
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-eks: eks.Cluster - Changing the subnets or securityGroupIds order causes an error
4 participants