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

service/apigateway: Fix schema set errors #13403

Merged
merged 3 commits into from
May 27, 2020
Merged

Conversation

appilon
Copy link
Contributor

@appilon appilon commented May 19, 2020

Removed undefined and unneeded request_validator_id from request validator import.
Set settings properly and return error, this required making the fields optional + computed. The acceptance tests would have never caught this error since the fields are user configurable, the config would be the defacto state.

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

Relates #13312

Release note for CHANGELOG:

* resource/aws_api_gateway_method_settings: `settings` now properly set

Output from acceptance testing:

❯ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayMethodSettings'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayMethodSettings -timeout 120m
=== RUN   TestAccAWSAPIGatewayMethodSettings_basic
=== PAUSE TestAccAWSAPIGatewayMethodSettings_basic
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_Multiple
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_Multiple
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit
=== RUN   TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy
=== PAUSE TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy
=== CONT  TestAccAWSAPIGatewayMethodSettings_basic
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_Multiple
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl
=== CONT  TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled (54.34s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds (54.57s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit (116.15s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_Multiple (149.83s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit (181.82s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_basic (251.95s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled (265.11s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy (279.81s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted (383.68s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl (476.06s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled (535.43s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel (536.97s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	539.755s

@appilon appilon requested a review from a team May 19, 2020 21:26
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/apigateway Issues and PRs that pertain to the apigateway service. labels May 19, 2020
@appilon appilon changed the title Fix schema set errors service/apigateway: Fix schema set errors May 19, 2020
@anGie44 anGie44 self-assigned this May 19, 2020
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

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

LGTM, @appilon 👍

I think we can overlook the failing acceptance test results (in APIGatewayMethodSettings) since they're unrelated?

@appilon
Copy link
Contributor Author

appilon commented May 20, 2020

Thanks for review @anGie44 , are you saying you did run the tests in CI and they fail unrelatedly? I haven't had a chance to setup that tool for kicking off specific tests

@appilon appilon added this to the v2.63.0 milestone May 20, 2020
@anGie44
Copy link
Contributor

anGie44 commented May 20, 2020

hmm I've looking over the results again and actually I think I may have based that comment on the Test History success rate 😞 ..in master the tests look to be passing and the results for this branch do show diffs in the settings attribute so they must be in some way related 😅 sorry for the confusion!

looking at the basic test, where the config only has the logging_level set in settings, it seems the API returns some default values causing the diff ... interesting, so previously setting a nested attribute like d.Set("settings.0.cache_enabled", ...) didn't actually set the field?

@appilon
Copy link
Contributor Author

appilon commented May 21, 2020

@anGie44 Previously all the settings fields would error, this meant that what was passed in user config would remain in state. This sort of "didn't error check, but all tests still pass" thing happens often as acceptance tests are trying to detect drift between Create and Read or Update and Read, but if Read isn't actually setting anything, then the acceptance test passes since the config becomes the state.

I will look into the failures but I suspect what you claim is right, now we ARE setting values and they don't align with config so we are getting drift.

UPDATE:
The the API response has some setting defaults, marked fields as optional + computed

@appilon appilon requested a review from anGie44 May 21, 2020 17:35
@appilon appilon force-pushed the b-apigateway-schema-panic branch from 43a9fd0 to 934e6be Compare May 21, 2020 17:35
@ghost ghost added 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 May 21, 2020
@appilon appilon removed this from the v2.63.0 milestone May 21, 2020
appilon added 3 commits May 26, 2020 21:32
Removed undefined and unneeded `request_validator_id` from request validator import.
Set `settings` properly and return error. The acceptance tests would have never caught
this error since the fields are user configurable, the config would be the defacto state.
@appilon appilon force-pushed the b-apigateway-schema-panic branch from 934e6be to 2e12262 Compare May 27, 2020 01:46
@appilon appilon requested a review from anGie44 May 27, 2020 02:06
@appilon appilon added this to the v2.64.0 milestone May 27, 2020
@anGie44
Copy link
Contributor

anGie44 commented May 27, 2020

Nice, I think semantically, using the Computed attribute makes sense here since the settings are set behind the scenes (and personally I didn't come across docs with defaults specified, though maybe in the console they're visible?) and perhaps future upstream changes will affect the defaults which would be cumbersome to keep up-to-date if the Default attribute were to be used instead.

Output of acceptance tests:

--- PASS: TestAccAWSAPIGatewayMethodSettings_basic (9.91s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled (40.82s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled (71.04s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds (106.59s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl (141.98s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit (142.27s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled (276.88s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy (368.59s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit (372.88s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel (373.72s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_Multiple (555.89s)
--- PASS: TestAccAWSAPIGatewayRequestValidator_basic (600.02s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted (670.64s)

@appilon
Copy link
Contributor Author

appilon commented May 27, 2020

Thanks @anGie44 , so this is approved?

@anGie44
Copy link
Contributor

anGie44 commented May 27, 2020

ah let's see, i think another look would be helpful before merging 😅. tagging @gdavison, @bflad for another set of eyes

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.

Using Computed: true for all the nested attributes is the safest option for now. 👍

@appilon appilon merged commit f64055c into master May 27, 2020
@appilon appilon deleted the b-apigateway-schema-panic branch May 27, 2020 19:56
@ghost
Copy link

ghost commented May 29, 2020

This has been released in version 2.64.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 Jun 27, 2020

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 Jun 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/apigateway Issues and PRs that pertain to the apigateway service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants