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

Add eks addon resource, data_source #16972

Merged
merged 9 commits into from
Apr 13, 2021
Merged

Add eks addon resource, data_source #16972

merged 9 commits into from
Apr 13, 2021

Conversation

juozasget
Copy link
Contributor

@juozasget juozasget commented Jan 5, 2021

This is my first contribution - feedback is very much welcome.

Thank you!

UPDATED & removed WIP mention

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #16542

Release note for CHANGELOG:

data-source/aws_eks_addon: new data-source
resource/aws_eks_addon: new resource

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSEksAddon*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSEksAddon* -timeout 120m
=== RUN   TestAccAWSEksAddonDataSource_basic
=== PAUSE TestAccAWSEksAddonDataSource_basic
=== RUN   TestAccAWSEksAddon_basic
=== PAUSE TestAccAWSEksAddon_basic
=== RUN   TestAccAWSEksAddon_disappears
=== PAUSE TestAccAWSEksAddon_disappears
=== RUN   TestAccAWSEksAddon_disappears_Cluster
=== PAUSE TestAccAWSEksAddon_disappears_Cluster
=== RUN   TestAccAWSEksAddons_AddonVersion
=== PAUSE TestAccAWSEksAddons_AddonVersion
=== RUN   TestAccAWSEksAddons_ResolveConflicts
=== PAUSE TestAccAWSEksAddons_ResolveConflicts
=== RUN   TestAccAWSEksAddons_ServiceAccountRoleArn
=== PAUSE TestAccAWSEksAddons_ServiceAccountRoleArn
=== RUN   TestAccAWSEksAddons_Tags
=== PAUSE TestAccAWSEksAddons_Tags
=== CONT  TestAccAWSEksAddonDataSource_basic
=== CONT  TestAccAWSEksAddons_ResolveConflicts
=== CONT  TestAccAWSEksAddon_disappears_Cluster
=== CONT  TestAccAWSEksAddons_AddonVersion
=== CONT  TestAccAWSEksAddon_basic
=== CONT  TestAccAWSEksAddon_disappears
=== CONT  TestAccAWSEksAddons_ServiceAccountRoleArn
=== CONT  TestAccAWSEksAddons_Tags
--- PASS: TestAccAWSEksAddons_AddonVersion (848.97s)
--- PASS: TestAccAWSEksAddon_basic (889.61s)
--- PASS: TestAccAWSEksAddonDataSource_basic (938.24s)
--- PASS: TestAccAWSEksAddons_ServiceAccountRoleArn (977.66s)
--- PASS: TestAccAWSEksAddon_disappears (981.65s)
--- PASS: TestAccAWSEksAddon_disappears_Cluster (986.26s)
--- PASS: TestAccAWSEksAddons_ResolveConflicts (1118.40s)
--- PASS: TestAccAWSEksAddons_Tags (1412.16s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1413.873s
...

@juozasget juozasget requested a review from a team as a code owner January 5, 2021 11:09
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/eks Issues and PRs that pertain to the eks service. labels Jan 5, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 5, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @juozasget 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/XL Managed by automation to categorize the size of a PR. labels Jan 11, 2021
@juozasget
Copy link
Contributor Author

@shuheiktgw @bflad Thank you very much for your initial comments.

I have updated original post with newly added ACC test outputs along with other missing things. I think the PR is now in good shape for a review. Things I'd like to point out:

  • Issue Support Managing EKS Cluster Add-Ons #16542 is only for resource, and this PR adds a data_source also. Let me know if you think it's not needed at all or if it should be moved and not done in scope of this PR.
  • There are some interesting interactions to consider when creating EKS Addon, when unmanaged version exists or when updating the addon and there are conflicts. Would definitely like some feedback on this part and if we should make some decision for the user and handle it or we should just throw an error and let the user handle it (current implementation).

I also left some TODO items, which would be nice to do/improve. I will try to work on them while waiting for feedback. 🔧
Thank you for waiting!

@juozasget juozasget requested review from bflad and removed request for a team January 11, 2021 13:00
Base automatically changed from master to main January 23, 2021 01:00
@juozasget
Copy link
Contributor Author

juozasget commented Jan 30, 2021

Hello. I've addressed the TODO things and improved the PR, mainly in these areas:

  • Added waiter package and moved relevant code there.
  • Fixed error handling according to newly released guidelines.
  • Improved error handling in the area I mentioned when add-on creation/update fails with information/warning for user.

I have been marinating this for 2-3 weeks, because after these improvements broke test case for TestAccAWSEksAddons_Tags. I've been pulling my hair out trying to find what could have caused this. I believe I've finally found it. Here are the details:

I added aws_eks_addon to aws_eks_cluster deps:
resource.AddTestSweepers("aws_eks_cluster", &resource.Sweeper{ Name: "aws_eks_cluster", F: testSweepEksClusters, Dependencies: []string{ "aws_eks_fargate_profile", "aws_eks_fargate_node_group", }, })

This caused the eks add-on deletion api to be called, before eks cluster deletion. Previously it would just delete the eks cluster. I believe that there might be some weird bug that will cause eks add-on to get stuck in DELETING state if the eks add-on had it's TAG values modified. This only happens if tag values were modified/set.

  1. Create EKS addon cia CLI with some tags.
  2. Modify the tags/put new tags on the created EKS addon via CLI.
  3. Delete the EKS addon.

Result: addon is stuck in DELETING state for 24+ hours. Example of 1 hours DELETION attached.

Opened question in AWS forum. Sadly I don't think there is much chance of getting an answer...
https://forums.aws.amazon.com/thread.jspa?threadID=334229&tstart=0

I've since removed it from sweeper dependencies and all test are passing. Not sure what to do about this.

@NeckBeardPrince
Copy link

Any chance we can review this PR again? Please.

@DonBower
Copy link

is this going to be merged?

@williamcodes
Copy link

Can we get this merged in? It's impossible to configure a fully functioning EKS cluster with managed nodes using only terraform right now because you can't install the VPC CNI addon.

Who needs to code review this? @shuheiktgw @bflad

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @juozasget. I've made some updates

Acceptance test results

--- PASS: TestAccAWSEksAddon_basic (772.00s)
--- PASS: TestAccAWSEksAddon_ServiceAccountRoleArn (830.59s)
--- PASS: TestAccAWSEksAddonDataSource_basic (857.39s)
--- PASS: TestAccAWSEksAddon_Tags (885.01s)
--- PASS: TestAccAWSEksAddon_disappears_Cluster (891.55s)
--- PASS: TestAccAWSEksAddon_disappears (946.00s)
--- PASS: TestAccAWSEksAddon_ResolveConflicts (976.91s)
--- PASS: TestAccAWSEksAddon_AddonVersion (989.17s)

"addon_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

ForceNew isn't needed on data sources


func dataSourceAwsEksAddon() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAwsEksAddonRead,
Copy link
Contributor

Choose a reason for hiding this comment

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

We're still working out the interactions between timeouts handled by the Terraform Context and the AWS API. To work around the interactions, we use the <operation>WithoutTimeout functions instead of <operation>Context functions.

Suggested change
ReadContext: dataSourceAwsEksAddonRead,
ReadWithoutTimeout: dataSourceAwsEksAddonRead,

Comment on lines +23 to +24
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSEks(t); testAccPreCheckAWSEksAddon(t) },
ProviderFactories: testAccProviderFactories,
Copy link
Contributor

Choose a reason for hiding this comment

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

We've added a parameter to handle acceptance test errors in a cleaner manner: https://github.com/hashicorp/terraform-provider-aws/blob/main/docs/contributing/running-and-writing-acceptance-tests.md#errorchecks

Suggested change
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSEks(t); testAccPreCheckAWSEksAddon(t) },
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSEks(t); testAccPreCheckAWSEksAddon(t) },
ErrorCheck: testAccErrorCheck(t, eks.EndpointsID),
ProviderFactories: testAccProviderFactories,


## Example Usage

```hcl
Copy link
Contributor

Choose a reason for hiding this comment

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

We prefer using terraform as the language name now

Suggested change
```hcl
```terraform

Comment on lines +93 to +94
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSEks(t); testAccPreCheckAWSEksAddon(t) },
ProviderFactories: testAccProviderFactories,
Copy link
Contributor

Choose a reason for hiding this comment

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

We've added a parameter to handle acceptance test errors in a cleaner manner: https://github.com/hashicorp/terraform-provider-aws/blob/main/docs/contributing/running-and-writing-acceptance-tests.md#errorchecks

Suggested change
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSEks(t); testAccPreCheckAWSEksAddon(t) },
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSEks(t); testAccPreCheckAWSEksAddon(t) },
ErrorCheck: testAccErrorCheck(t, eks.EndpointsID),
ProviderFactories: testAccProviderFactories,

@gdavison gdavison merged commit 171a9da into hashicorp:main Apr 13, 2021
@github-actions github-actions bot added this to the v3.37.0 milestone Apr 13, 2021
@ghost
Copy link

ghost commented Apr 16, 2021

This has been released in version 3.37.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!

@ghost
Copy link

ghost commented May 13, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators May 13, 2021
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/eks Issues and PRs that pertain to the eks service. size/XXL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Managing EKS Cluster Add-Ons
8 participants