-
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
Autoscaling Opsworks Configuration #3165
Conversation
make testacc TEST=./aws TESTARGS='-run=TestAccAWSOpsworksCustomLayer' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -run=TestAccAWSOpsworksCustomLayer -timeout 120m === RUN TestAccAWSOpsworksCustomLayerImportBasic --- PASS: TestAccAWSOpsworksCustomLayerImportBasic (107.21s) === RUN TestAccAWSOpsworksCustomLayer --- PASS: TestAccAWSOpsworksCustomLayer (104.25s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 211.472s
If you have any proposal of change I can work on it! |
I'm really interested in this one. For now I have this one merged in my custom plugin but would really like it to be merged upstream. Also I would propose 2 changes.
|
Thanks to review it! |
Nice PR btw. I am currently using it in production. Do you know if there is any update as to when this is going to be merged upstream? |
No, sorry! |
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.
Hi @eduherraiz 👋 Sorry for the lengthy review delay. We have quite the backlog to work through. 😅
I left some initial comments below and am curious if you can implement the feedback suggested by @commixon as well. Let us know if you don't have time or have any questions, thanks!
aws/opsworks_layers.go
Outdated
return err | ||
} | ||
|
||
if autoScalings.LoadBasedAutoScalingConfigurations == nil || len(autoScalings.LoadBasedAutoScalingConfigurations) == 0 { |
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.
This section could be simplified to:
d.Set("autoscaling", false)
if autoScalings.LoadBasedAutoScalingConfigurations != nil && len(autoScalings.LoadBasedAutoScalingConfigurations) != 0 && autoScalings.LoadBasedAutoScalingConfigurations[0] != nil {
lt.SetAutoscaling(d, autoScalings.LoadBasedAutoScalingConfigurations[0])
}
@@ -308,7 +386,20 @@ resource "aws_opsworks_custom_layer" "tf-acc" { | |||
mount_point = "/home" | |||
size = 100 | |||
raid_level = 0 | |||
} | |||
}, | |||
autoscaling = true |
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.
Could you please split this out into its own acceptance test configuration and acceptance test function? We should verify that not having these specified does not generate any unexpected differences. 👍
LayerId: aws.String(d.Id()), | ||
DownScaling: &opsworks.AutoScalingThresholds{ | ||
Alarms: expandStringList(d.Get("downscaling_alarms").([]interface{})), | ||
CpuThreshold: aws.Float64(float64(d.Get("downscaling_cpu_threshold").(float64))), |
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.
FYI, these float64()
of float64
types are triggering make lint
failures in CI since they are unnecessary:
$ make lint
==> Checking source code against linters...
aws/opsworks_layers.go:1::warning: file is not gofmted with -s (gofmt)
aws/opsworks_layers.go:774:43:warning: unnecessary conversion (unconvert)
aws/opsworks_layers.go:777:43:warning: unnecessary conversion (unconvert)
aws/opsworks_layers.go:778:43:warning: unnecessary conversion (unconvert)
aws/opsworks_layers.go:783:43:warning: unnecessary conversion (unconvert)
aws/opsworks_layers.go:786:43:warning: unnecessary conversion (unconvert)
aws/opsworks_layers.go:787:43:warning: unnecessary conversion (unconvert)
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.
Oh! Thank you. I will check it tomorrow.
Hi @eduherraiz 👋 Will you have a chance to finish this up? No worries if not, just please let us know so one of the community members or maintainers can pick this up. Thanks! |
I think the code is working properly. |
While the idea here is good, there are some issues with this implementation. By default, right now, these settings are set as follows within the AWS API when creating a brand new OpsWorks Layer from scratch:
Note the default values, as well as the Even if you don't want to enable this setting, but try to apply the default Threshold values in this PR as -1 (disabled), the AWS API will throw an exception:
It seems as if at least one threshold value must be set, even if the load based autoscaling is disabled all together. So, this PR as is will not work currently because, if you did not set any of these values, they will be initialized all as -1, and the apply will fail. We could slightly work around this by setting the defaults as they truly are in the AWS API, namely:
But then you run into a scenario where you'd need to explicitly set the thresholds you don't care about to -1 to disable them. Which is neither a standard pattern nor super intuitive. Finally, I think a more preferably structure for setting this in HCL would look like:
This would give the added benefit of being able to reuse the internal complex structure for both downscaling and upscaling. |
Hello @xsalazar, thank you for your comments! |
@eduherraiz I figured given how old this PR was, it was past its relevance! I just ran into the issue of needing to provision this setting recently and dug into your solution to solve it upstream! Thank you for the initial work; I'm definitely still thinking about working on it some more when I have time |
Can we close this one in favor of #10962 ? |
Pull request #21306 has significantly refactored the AWS Provider codebase. As a result, most PRs opened prior to the refactor now have merge conflicts that must be resolved before proceeding. Specifically, PR #21306 relocated the code for all AWS resources and data sources from a single We recognize that many pull requests have been open for some time without yet being addressed by our maintainers. Therefore, we want to make it clear that resolving these conflicts in no way affects the prioritization of a particular pull request. Once a pull request has been prioritized for review, the necessary changes will be made by a maintainer -- either directly or in collaboration with the pull request author. For a more complete description of this refactor, including examples of how old filepaths and function names correspond to their new counterparts: please refer to issue #20000. For a quick guide on how to amend your pull request to resolve the merge conflicts resulting from this refactor and bring it in line with our new code patterns: please refer to our Service Package Refactor Pull Request Guide. |
Superseded by #10962. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Added in opsworks_custom_layer the necessary options to configure load parameters
I follow the contributing indications in order to:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSOpsworksCustomLayer' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -run=TestAccAWSOpsworksCustomLayer -timeout 120m === RUN TestAccAWSOpsworksCustomLayerImportBasic --- PASS: TestAccAWSOpsworksCustomLayerImportBasic (107.21s) === RUN TestAccAWSOpsworksCustomLayer --- PASS: TestAccAWSOpsworksCustomLayer (104.25s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 211.472s