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

[Elasticsearch] Implement specifying availability zone count ... #8144

Closed
wants to merge 6 commits into from

Conversation

jtcressy
Copy link

@jtcressy jtcressy commented Apr 1, 2019

... when zone awareness is enabled

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #7504

Changes proposed in this pull request:

  • add parameter in cluster_config: zone_awareness_count
    • parameter is mapped to config.ZoneAwarenessConfig.AvailabilityZoneCount as int64
  • add acceptance test case TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ
    • creates 3 t2.micro.elasticsearch nodes across 3 az's with zone awareness to test this PR

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ
=== PAUSE TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ
=== CONT  TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ
--- PASS: TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ (772.59s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       797.900s
  

Implemented my own tests for this. It's based off of TestAccAWSElasticSearchDomain_basic and simply uses cluster_config to deploy 3 nodes across 3 AZ's.

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/elasticsearch Issues and PRs that pertain to the elasticsearch service. labels Apr 1, 2019
aws/structure.go Outdated Show resolved Hide resolved
@ghost ghost added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Apr 4, 2019
@jtcressy jtcressy changed the title [WIP] [Elasticsearch] Implement specifying availability zone count ... [Elasticsearch] Implement specifying availability zone count ... Apr 4, 2019
@jtcressy
Copy link
Author

jtcressy commented Apr 4, 2019

Removed the WIP marker, as I think this PR is ready for review! It even has tests now! 😄

@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Apr 5, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @jtcressy 👋 Thanks for submitting this. This will need a few things adjusted before it can be accepted. Please let us know if you have any questions or do not have time to implement the feedback.

Currently the other acceptance testing is failing:

--- FAIL: TestAccAWSElasticSearchDomain_update (35.17s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: NumberOfAvailabilityZones should be either 2 or 3
        	status code: 400, request id: d692895f-5748-11e9-9abc-25f5949255f2

--- FAIL: TestAccAWSElasticSearchDomain_update_version (8.20s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: ZoneAwarenessEnabled must be set to True to specify the ZoneAwarenessSettings
        	status code: 400, request id: db7a06b6-5748-11e9-b707-5f7cde003491

--- FAIL: TestAccAWSElasticSearchDomain_encrypt_at_rest_default_key (54.06s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: ZoneAwarenessEnabled must be set to True to specify the ZoneAwarenessSettings
        	status code: 400, request id: e19f0e51-5748-11e9-b09e-1de5efe18623

--- FAIL: TestAccAWSElasticSearchDomain_complex (71.68s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: NumberOfAvailabilityZones should be either 2 or 3
        	status code: 400, request id: ec15bc6d-5748-11e9-b09e-1de5efe18623

--- FAIL: TestAccAWSElasticSearchDomain_encrypt_at_rest_specify_key (82.53s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: ZoneAwarenessEnabled must be set to True to specify the ZoneAwarenessSettings
        	status code: 400, request id: e62a3b8a-5748-11e9-b15e-f3e3bdb4bca1

--- FAIL: TestAccAWSElasticSearchDomain_vpc_update (87.55s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: NumberOfAvailabilityZones should be either 2 or 3
        	status code: 400, request id: f35f1f92-5748-11e9-ab97-b33e6d431941

--- FAIL: TestAccAWSElasticSearchDomain_update_volume_type (90.56s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: NumberOfAvailabilityZones should be either 2 or 3
        	status code: 400, request id: f7536447-5748-11e9-a09a-4f2eaa601f9d

--- FAIL: TestAccAWSElasticSearchDomain_vpc (107.82s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: NumberOfAvailabilityZones should be either 2 or 3
        	status code: 400, request id: f8369866-5748-11e9-82e4-ab4437639e4f

--- FAIL: TestAccAWSElasticSearchDomain_NodeToNodeEncryption (195.56s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: ZoneAwarenessEnabled must be set to True to specify the ZoneAwarenessSettings
        	status code: 400, request id: 35fc3149-5749-11e9-997c-35621615dd41

--- FAIL: TestAccAWSElasticSearchDomain_withDedicatedMaster (221.49s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: ZoneAwarenessEnabled must be set to True to specify the ZoneAwarenessSettings
        	status code: 400, request id: 454d1792-5749-11e9-8cfc-a9b4ddbad0eb

--- FAIL: TestAccAWSElasticSearchDomain_internetToVpcEndpoint (669.04s)
    testing.go:538: Step 1 error: Error applying: 1 error occurred:
        	* aws_elasticsearch_domain.example: 1 error occurred:
        	* aws_elasticsearch_domain.example: ValidationException: NumberOfAvailabilityZones should be either 2 or 3
        	status code: 400, request id: 4e0afc85-574a-11e9-a303-6be082a5aae1

@@ -194,6 +194,10 @@ func resourceAwsElasticSearchDomain() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"zone_awareness_count": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Two notes:

  • This argument needs documentation added in website/docs/r/elasticsearch_domain.html.markdown
  • Since this argument is not marked ForceNew: true, an additional TestStep should be added to the acceptance test that attempts to update or remove it

testAccCheckESDomainExists("aws_elasticsearch_domain.example", &domain),
resource.TestCheckResourceAttr(
"aws_elasticsearch_domain.example", "elasticsearch_version", "1.5"),
resource.TestMatchResourceAttr("aws_elasticsearch_domain.example", "kibana_endpoint", regexp.MustCompile(".*es.amazonaws.com/_plugin/kibana/")),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be testing the new attribute instead? e.g.

Suggested change
resource.TestMatchResourceAttr("aws_elasticsearch_domain.example", "kibana_endpoint", regexp.MustCompile(".*es.amazonaws.com/_plugin/kibana/")),
resource.TestCheckResourceAttr("aws_elasticsearch_domain.example", "cluster_config.0.zone_awareness_count", "3"),

Copy link
Author

Choose a reason for hiding this comment

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

Ok, i'm taking this recommendation and expanding it to multiple test steps:

  1. zone awareness disabled and zone awareness count set to 3
  2. update cluster with zone awareness enabled
  3. update cluster again with zone awareness disabled
  4. update cluster with zone awareness enabled and count set to 2
  5. update cluster zone aware count to 3

@jtcressy
Copy link
Author

jtcressy commented Apr 5, 2019

@bflad So, when the vpc_update validation exception of NumberOfAvailabilityZones should be either 2 or 3 occurs, the test seems to be setting zone_awareness_enabled = true but only supplying one subnet in the vpc_config. I'm not sure if this is something I affected by my change. I'll let you know if I still encounter it in my tests.

I've got some changes in strucutre.go to mimic the control structure of setting the dedicated master parameters, and i'll be committing/pushing it soon. I think it'll fix some of the problems we have right now.

@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Apr 5, 2019
@jtcressy
Copy link
Author

jtcressy commented Apr 5, 2019

@bflad BTW, make testacc TESTARGS='-run=TestAccAWSElasticSearchDomain' is extremely slow... if you have any tips to make this testing phase run faster i'm all ears.

@nywilken
Copy link
Contributor

nywilken commented Apr 5, 2019

@bflad BTW, make testacc TESTARGS='-run=TestAccAWSElasticSearchDomain' is extremely slow... if you have any tips to make this testing phase run faster i'm all ears.

The string after run= works as a regex expression to match tests to run. You can filter down the selected test cases by narrowing down the scope of the matching expression. For examplemake testacc TESTARGS='-run=TestAccAWSElasticSearchDomain_ZoneAwarenessWith3AZ' will only run this specific test. In order to help speed things up it may help to attack one or two test cases at a time.

Sorry I should mention that you can use the OR operator to call out two distinct test cases

make testacc TESTARGS='-run=TestAccAWSElasticSearchDomain_basic\|TestAccAWSElasticSearchDomain_Zone'

@bflad
Copy link
Contributor

bflad commented Apr 5, 2019

Unfortunately the limiting factor here is the AWS Elasticsearch service itself where each of the create/update/delete operations can take 5-60 minutes to complete. I have not seen the default 20 parallelism of the acceptance testing be of any particular problem to the service since most of wait time is polling read-only APIs for a status update and not caused by API retries due to throttling.

@keety
Copy link

keety commented May 30, 2019

@jtcressy, @bflad thanks for aws_elasticsearch_domain support it has been super useful and I use it extensively to provision elasticsearch on aws. .
I'm pinging this thread since #7504 seems to have a dependency on this .
Was curious if this is being fixed in v2.13.0 or if there was a specific version the fix was targeted for ?

@neovatar
Copy link

neovatar commented Jun 6, 2019

What needs to be done to get this PR merged? It would be great, if we could create a 3 AZ elasticsearch domain with terraform.

@aeschright aeschright requested a review from a team June 26, 2019 00:54
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @jtcressy 👋 Its been awhile since we heard from you and it looks like the acceptance testing is still failing in some places (see below). Do you need any assistance or still have time to work on this? The new argument also needs documentation in website/docs/r/elasticsearch_domain.html.markdown. Thanks!

--- FAIL: TestAccAWSElasticSearchDomain_ZoneAwareness (2028.78s)
    testing.go:568: Step 0 error: Check failed: Check 3/3 error: aws_elasticsearch_domain.example: Attribute 'cluster_config.0.zone_awareness_count' expected "3", got "0"

--- FAIL: TestAccAWSElasticSearchDomain_complex (8.79s)
    testing.go:568: Step 0 error: errors during apply:
        
        Error: ValidationException: NumberOfAvailabilityZones should be either 2 or 3

--- FAIL: TestAccAWSElasticSearchDomain_internetToVpcEndpoint (1349.31s)
    testing.go:568: Step 1 error: errors during apply:
        
        Error: ValidationException: NumberOfAvailabilityZones should be either 2 or 3

--- FAIL: TestAccAWSElasticSearchDomain_update (9.06s)
    testing.go:568: Step 0 error: errors during apply:
        
        Error: ValidationException: NumberOfAvailabilityZones should be either 2 or 3

--- FAIL: TestAccAWSElasticSearchDomain_update_volume_type (62.50s)
    testing.go:568: Step 0 error: errors during apply:
        
        Error: ValidationException: NumberOfAvailabilityZones should be either 2 or 3

--- FAIL: TestAccAWSElasticSearchDomain_vpc (63.80s)
    testing.go:568: Step 0 error: errors during apply:
        
        Error: ValidationException: NumberOfAvailabilityZones should be either 2 or 3

--- FAIL: TestAccAWSElasticSearchDomain_vpc_update (66.13s)
    testing.go:568: Step 0 error: errors during apply:
        
        Error: ValidationException: NumberOfAvailabilityZones should be either 2 or 3

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jul 10, 2019
@jtcressy
Copy link
Author

Hi @bflad, please take over if you have the means/time. I've been swamped at work and haven't had the time to make progress on this PR.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 10, 2019
@bflad
Copy link
Contributor

bflad commented Jul 17, 2019

No worries, @jtcressy! Thank you so much for your hard work on this. We hope you can contribute again in the future.

I've opened #9398 which includes your commits. Please follow that pull request for further tracking of this functionality. 👍

@bflad bflad closed this Jul 17, 2019
@ghost
Copy link

ghost commented Nov 2, 2019

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 and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/elasticsearch Issues and PRs that pertain to the elasticsearch service. size/M 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 for AWS Elasticsearch across 3 availability zones
6 participants