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

resource/autoscaling_policy: fix conditional logic based on policy type #3739

Merged

Conversation

loivis
Copy link
Contributor

@loivis loivis commented Mar 11, 2018

fix #3715
fix #3689

Issue with current approach is that even user doesn't set the argument, it will be set to zero in terraform state from aws api response as placeholder. Later on during update, zero value is used thus trigger the error. One way to fix is to add conditional logic in read function as well. I'm not feeling comfortable with this because multiple conditions are introduced to handle the same situation.

Instead, I'm changing the logic in the same place to set arguments only for valid policy types. With checking policy type before setting input parameter, it's also easily compare each parameter with api specification.

I didn't figure out how to distinguish zero value between user input and terraform state value in current logic but that's not the focus here.

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 11, 2018
@ghost ghost added size/L Managed by automation to categorize the size of a PR. size/XL Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. size/L Managed by automation to categorize the size of a PR. labels Mar 11, 2018
@loivis loivis changed the title [WIP]resource/autoscaling_policy: fix conditional logic based on policy type resource/autoscaling_policy: fix conditional logic based on policy type Mar 11, 2018
@loivis loivis changed the title resource/autoscaling_policy: fix conditional logic based on policy type [WIP]resource/autoscaling_policy: fix conditional logic based on policy type Mar 11, 2018
@loivis loivis force-pushed the 3715-autoscaling_policy-scaling_adjustment branch from f3c3e99 to 738e6ae Compare March 11, 2018 20:46
@ghost ghost added the size/XL Managed by automation to categorize the size of a PR. label Mar 11, 2018
@loivis
Copy link
Contributor Author

loivis commented Mar 11, 2018

⎇  make fmt; and echo > aws/debug.log ; and make testacc TEST=./aws TESTARGS='-run=TestAccAWSAutoscalingPolicy_'
gofmt -w $(find . -name '*.go' |grep -v vendor)
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSAutoscalingPolicy_ -timeout 120m
=== RUN   TestAccAWSAutoscalingPolicy_basic
--- PASS: TestAccAWSAutoscalingPolicy_basic (139.01s)
=== RUN   TestAccAWSAutoscalingPolicy_disappears
--- PASS: TestAccAWSAutoscalingPolicy_disappears (104.02s)
=== RUN   TestAccAWSAutoscalingPolicy_upgrade
--- PASS: TestAccAWSAutoscalingPolicy_upgrade (132.35s)
=== RUN   TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment
--- PASS: TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment (99.10s)
=== RUN   TestAccAWSAutoscalingPolicy_TargetTrack_Predefined
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Predefined (103.59s)
=== RUN   TestAccAWSAutoscalingPolicy_TargetTrack_Custom
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Custom (97.17s)
=== RUN   TestAccAWSAutoscalingPolicy_zerovalue
--- PASS: TestAccAWSAutoscalingPolicy_zerovalue (99.81s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	775.102s

@loivis loivis changed the title [WIP]resource/autoscaling_policy: fix conditional logic based on policy type resource/autoscaling_policy: fix conditional logic based on policy type Mar 11, 2018
@tilgovi
Copy link

tilgovi commented Mar 11, 2018

I expect this will fix #3689 also

@loivis loivis changed the title resource/autoscaling_policy: fix conditional logic based on policy type [wip]resource/autoscaling_policy: fix conditional logic based on policy type Mar 12, 2018
@ghost ghost added the size/XL Managed by automation to categorize the size of a PR. label Mar 12, 2018
@loivis loivis changed the title [wip]resource/autoscaling_policy: fix conditional logic based on policy type resource/autoscaling_policy: fix conditional logic based on policy type Mar 12, 2018
@loivis loivis force-pushed the 3715-autoscaling_policy-scaling_adjustment branch from 8d81b75 to f748693 Compare March 12, 2018 15:48
@ghost ghost added the size/XL Managed by automation to categorize the size of a PR. label Mar 12, 2018
@radeksimko radeksimko added bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. labels Mar 13, 2018
@tyjonesAncestry
Copy link

Can we get this merged? This is actively breaking us in Prod as well.

@tilgovi
Copy link

tilgovi commented Mar 13, 2018

We're only a few days out from the initial report and there is a complete PR. Thank you, @loivis!

@mathematician
Copy link
Contributor

When could this be merged? I am unsure if the documentation for autoscaling_policy works in its current state at all.

@bflad bflad added this to the v1.13.0 milestone Mar 27, 2018
@bflad bflad self-requested a review March 27, 2018 22:03
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.

LGTM, thanks for fixing this. Sorry this took some extra time for review since it was quite large.

 7 tests passed (all tests)
=== RUN   TestAccAWSAutoscalingPolicy_TargetTrack_Predefined
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Predefined (56.48s)
=== RUN   TestAccAWSAutoscalingPolicy_TargetTrack_Custom
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Custom (59.59s)
=== RUN   TestAccAWSAutoscalingPolicy_zerovalue
--- PASS: TestAccAWSAutoscalingPolicy_zerovalue (61.08s)
=== RUN   TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment
--- PASS: TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment (74.00s)
=== RUN   TestAccAWSAutoscalingPolicy_disappears
--- PASS: TestAccAWSAutoscalingPolicy_disappears (98.28s)
=== RUN   TestAccAWSAutoscalingPolicy_upgrade
--- PASS: TestAccAWSAutoscalingPolicy_upgrade (121.46s)
=== RUN   TestAccAWSAutoscalingPolicy_basic
--- PASS: TestAccAWSAutoscalingPolicy_basic (123.73s)

@bflad bflad merged commit d455d5c into hashicorp:master Mar 28, 2018
bflad added a commit that referenced this pull request Mar 28, 2018
@bflad
Copy link
Contributor

bflad commented Mar 29, 2018

This has been released in version 1.13.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 7, 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 Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service. size/XL Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Step scaling policies cannot be modified Auto scaling target tracking policies confused by cooldown
6 participants