-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add stickiness support for NLB target_groups #15295
Conversation
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.
@madpipeline This looks great! Thank you for your work on this. Acceptance tests are passing. There are only two things we need before we can merge: a documentation update (website/docs/r/lb_target_group.html.markdown
) and a test for the new value (aws/resource_aws_lb_target_group_test.go
). Would you be willing to add these?
--- PASS: TestLBTargetGroupCloudwatchSuffixFromARN (0.54s)
--- PASS: TestAccAWSLBTargetGroup_withoutHealthcheck (49.26s)
--- PASS: TestAccAWSLBTargetGroup_Protocol_Tls (55.92s)
--- PASS: TestAccAWSLBTargetGroup_BackwardsCompatibility (64.22s)
--- PASS: TestAccAWSLBTargetGroup_basicUdp (64.93s)
--- PASS: TestAccAWSLBTargetGroup_namePrefix (64.95s)
--- PASS: TestAccAWSLBTargetGroup_generatedName (67.61s)
--- PASS: TestAccAWSLBTargetGroup_basic (81.96s)
--- PASS: TestAccAWSLBTargetGroupAttachment_lambda (83.06s)
--- PASS: TestAccAWSLBTargetGroup_networkLB_TargetGroupWithProxy (113.30s)
--- PASS: TestAccAWSLBTargetGroup_changeNameForceNew (120.44s)
--- PASS: TestAccAWSLBTargetGroup_TCP_HTTPHealthCheck (123.12s)
--- PASS: TestAccAWSLBTargetGroup_stickinessWithTCPEnabledShouldError (11.54s)
--- PASS: TestAccAWSLBTargetGroup_changeProtocolForceNew (126.08s)
--- PASS: TestAccAWSLBTargetGroup_changePortForceNew (126.42s)
--- PASS: TestAccAWSLBTargetGroup_Protocol_Tcp_HealthCheck_Protocol (127.86s)
--- PASS: TestAccAWSLBTargetGroupAttachment_BackwardsCompatibility (129.86s)
--- PASS: TestAccAWSLBTargetGroup_defaults_application (63.61s)
--- PASS: TestAccAWSLBTargetGroupAttachment_basic (133.31s)
--- PASS: TestAccAWSLBTargetGroup_stickinessWithTCPDisabled (52.81s)
--- PASS: TestAccAWSLBTargetGroupAttachment_Port (140.71s)
--- PASS: TestAccAWSLBTargetGroupAttachment_disappears (143.58s)
--- PASS: TestAccAWSLBTargetGroup_changeVpcForceNew (97.31s)
--- PASS: TestAccAWSLBTargetGroup_defaults_network (65.93s)
--- PASS: TestAccAWSLBTargetGroup_enableHealthCheck (85.06s)
--- PASS: TestAccAWSLBTargetGroupAttachment_ipAddress (150.13s)
--- PASS: TestAccAWSLBTargetGroup_updateHealthCheck (87.33s)
--- PASS: TestAccAWSLBTargetGroup_networkLB_TargetGroup (152.79s)
--- PASS: TestAccAWSLBTargetGroup_tags (105.88s)
--- PASS: TestAccAWSLBTargetGroup_updateSticknessEnabled (99.57s)
Hey @YakDriver. Sure. I can handle the docs, but I'm not sure how to add the test, since I see right now there are no UDP tests, and I'd like to keep your tests pattern. Any advice on how to add that test? I could use a hand with it. |
No problem. The 10,000 ft overview is that there's a basic test that should test everything possible. Each additional test should only test specifically what it's about since the basic test has the bases covered. Here's a short overview of acceptance testing. For context, the basic test for You want to create a test and the config/HCL that the test will need. This will involve adding probably two functions: the test and a function that returns a big string with the config. You can use this test as a template: https://github.com/terraform-providers/terraform-provider-aws/blob/baf451417714e7e3498b5468a7bd39727c647ca5/aws/resource_aws_lb_target_group_test.go#L967-L989. The config for that test is here: https://github.com/terraform-providers/terraform-provider-aws/blob/baf451417714e7e3498b5468a7bd39727c647ca5/aws/resource_aws_lb_target_group_test.go#L1926-L1948 Basically, copy/paste those functions, rename them, change the config, make sure the test is testing for what you've added, and Bob's your uncle. Here are more in-depth docs and we're always here to help! |
It seems that the changes are not so easy. Stickiness is now allowed with NLBs acording to the docs. So I'll make some more changes to alter the TCP behaviour regarding stickiness. Not sure yet if embarking on this change wagon is a good idea or not. |
I have a WIP for the tests, but it's not clean yet, so I'm not ready to commit them. |
@madpipeline Excellent! Thanks for continuing on with this. I recognize this is probably not the only thing you've got going on so I appreciate your willingness to continue and keeping us informed about your status. If you get stuck or want to bounce anything off me, please feel free. (I add the "waiting response" label to help organize things on my end and not to put any pressure on you!) |
Tests seem ok. However, I can't find in the CI logs the per test output you've sent in a previous message. I wanted to see the new tests I've added in that list. Please review and let me know if I need to change anything, or you disagree with my approach. |
@madpipeline My first impression is that this is looking great! Thanks for your work on it. I have some quick questions and will take a closer look shortly.
|
@YakDriver I've added those before I've figured out how to set the default type for NLB TG. They are not needed. I've removed them. I wanted to use API enums for the type literals, but didn't find any. I've considered creating my own |
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.
@madpipeline Thank you for all your help with this! I made a few changes in order to get it in. I share with you a couple of lessons from this:
- The creation process usually involves 3 parts: Create, Update, Read. In order to reduce duplication in the code, generally Create does a very basic create of a skeleton resource. The Create function only needs to check for things that would prevent the creation of the "skeleton". Then, the creation process goes to Update where everything is modified to look like the config. Most of the work is done in Update. Finally, the last part of the creation process is Read. This basically checks to make sure the config, state, and infrastructure are the same. If not, you get a non-empty plan.
- Generally you want to avoid breaking changes unless there's a very good reason. For example, there is a default
cookie_duration
. This could cause problems because the AWS API will give an error if you send acookie_duration
for thesource_ip
type. Then there's another problem because if the config says 86400, which is what happens when there is a default and nocookie_duration
, but AWS says there is nocookie_duration
, the two don't match and you end up with non-empty plans. But, getting rid of the default could break people's configs if they rely on it. Thus, I kept the default but added aDiffSuppressFunc
to avoid the default causing problems. - If possible, let the AWS API do the error checking. It does take longer to wait for errors to come back but it is more sustainable. The API changes a lot and if we duplicate the error checking, we'll have to change a lot too. Here, instead of checking for problems with stickiness types and protocols, I let the documentation and the AWS API take care of it. I was able to remove all the error checking for that.
Let me know if you have any questions! Thank you for all your work on this. Great job! 💯
The output from acceptance tests (Commercial):
The output from acceptance tests (GovCloud):
|
I'm guessing that as people use this, other problems will surface. But, that's the nature of small incremental changes made often! Thanks again for your contribution. We look forward to your help again! |
This has been released in version 3.10.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
Potentially helpful notes for this resource that I'll leave here:
|
These should go in a new issue. It will get buried here. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Closes #9093
Closes #13762
Release note for CHANGELOG:
This PR is meant to update the #13762, that has a minor syntax issue and no response from the author.
References