-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Update Application Auto Scaling to support scaling an Amazon EC2 Spot fleet. #8697
Update Application Auto Scaling to support scaling an Amazon EC2 Spot fleet. #8697
Conversation
I think this is OK for review. Some notes:
|
Optional: true, | ||
Default: "ecs:service:DesiredCount", | ||
ForceNew: true, | ||
Type: schema.TypeString, |
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.
If we are changing these from Optional to required, then we may need to verify that the default value from before ecs:service:DesiredCount
is actually correct - otherwise we are breaking backwards compatibility
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.
ecs:service:DesiredCount
is still a valid value.
Hi @niclic thanks for the PR here - there are some alarming changes for backward compatibility purposes - we may need to test this with 0.7.3 and then apply the changes on top and see if the tests still pass With regards to the SDK update, I will open a PR that will update that - watch out for that tomorrow Paul |
Hi Paul, RE: changing
If this change is too much, the original default values could be restored, although I think this is less than ideal. This only makes sense to maintain some sort of back compatibility; obviously these are not sensible defaults if you intend to scale a spot fleet request. These are service-specific defaults. That was my concern. With the current service-specific defaults, additional validation would be needed to to ensure that the choice of values for Ray |
I ran a series of test using the test files included below. I first created the I then ran When no values for When switching to
To proceed, I have to provide explicit values for the now required attributes. When explicit values for |
Test file for above tests. Explicit values are commented out.
|
To reiterate, I recommend removing the current default values, because they no longer make sense for the newly added Amazon EC2 Spot fleet requests service (or any other services that may be added in the future), even though this breaks compatibility with the previous release of these resources. If the default values stay, then they only make sense for scaling ECS services. Some sort of validation or substitution code will have to be added and maintained to For example, some validation code like this: func getAwsAppautoscalingPutScalingPolicyInput(d *schema.ResourceData) (applicationautoscaling.PutScalingPolicyInput, error) {
// existing code
var params = applicationautoscaling.PutScalingPolicyInput{
PolicyName: aws.String(d.Get("name").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
}
if v, ok := d.GetOk("service_namespace"); ok {
params.ServiceNamespace = aws.String(v.(string))
}
if v, ok := d.GetOk("scalable_dimension"); ok {
params.ScalableDimension = aws.String(v.(string))
}
// new code
sp, err := getExpectedScalingParameters(params.ResourceId)
if err != nil {
return fmt.Errorf("Error creating AppAutoscaling input", err)
}
if params.ScalableDimension != sp.ScalableDimension {
return fmt.Errorf("scalable_dimension is not valid for this resource type %s", params.ResourceId)
}
if params.ServiceNamespace != sp.ServiceNamespace {
return fmt.Errorf("service_namespace is not valid for this resource type %s", params.ResourceId)
}
// ...
}
// new
type ScalingParameters struct {
ScalableDimension, ServiceNamespace string
}
// new
func getExpectedScalingParameters(resourceId string) (ScalingParameters, error) {
params := ScalingParameters{}
i := strings.Index(resourceId, "/")
if i == -1 {
return params, fmt.Errorf("Invalid resourceId: %s", resourceId)
}
switch service := resourceId[:i]; service {
case "service":
params.ScalableDimension = "ecs:service:DesiredCount"
params.ServiceNamespace = "ecs"
case "spot-fleet-request":
params.ScalableDimension = "ec2:spot-fleet-request:TargetCapacity"
params.ServiceNamespace = "ec2"
default:
return params, fmt.Errorf("Unsupported AWS Service: %s", service)
}
return params, nil
} This sort of code can become outdated with each service update. Having said that, I'm sure it's possible to tighten this up (I don't work with the go language). I still think the best approach is to require the user to enter the appropriate values for Thoughts? |
I'd like to resolve the conflicts with this branch and hopefully get it merged in soon. Do you have a preferred approach to doing that (merge commit vs rebase and force push)? I have made a lot of comments above, but here is the TLDR:
|
+1 Any status on this? I'm waiting on this feature. |
To reiterate my last comment, I think this is good to go. However, since the last update, Application Auto Scaling now supports scaling EMR clusters. This means a new scalable dimension and service namespace combination can be added. This should be a very quick and simple change. Should this feature be added to this PR? It might be worth adding it here since a rebase is already needed to resolve conflicts in the shared validators files, which would need updating again to support EMR. It would be a shame to wait so long again for this capability to be added. I await confirmation from @stack72 and anybody else interested in this feature. I really hope that this can get resolved and merged soon. Other gaps to be aware of:
|
Hi @niclic Sorry for not getting back to you - I agree, the EMR side of that is outside of the scope of this PR. If possible, please can you rebase this 1 last time and I will give this a final review and get it merged today Thanks Paul |
- Add support for automatically scaling an Amazon EC2 Spot fleet.
- aws_appautoscaling_policy - aws_appautoscaling_target
- No arn is generated or returned for this resource.
- ScalableTargets do not have a name - I think this was copied from aws_appautoscaling_policy
- include a target resource in the policy example - sort attributes by alpha - fixup markdown - add spaces to test config
2aefbaa
to
cdb2ee0
Compare
I have rebased the commits in this PR to resolve the conflicts in Can you review and merge soon? I notice that work has already started on adding EMR support to Application Auto Scaling so this PR should definitely get merged soon to avoid any problems (cf. #11126). |
On it :) |
Great! One last point, it is probably a good idea to include a note in the CHANGELOG or Release Notes to indicate that there are no longer any defaults for |
Hi @niclic Thanks for all the work here - the changes now LGTM and the tests are green. You are correct about adding a NOTE to the changelog on this - I will take care of this - thanks for being so patient :)
|
… fleet. (#8697) * provider/aws: Update Application Auto Scaling service model - Add support for automatically scaling an Amazon EC2 Spot fleet. * Remove duplicate policy_type check. * Test creating a scalable target for a splot fleet request. * Test creating a scaling policy for a splot fleet request. * Update resource docs to support scaling an Amazon EC2 Spot fleet. - aws_appautoscaling_policy - aws_appautoscaling_target * Remove arn attribute from aws_appautoscaling_target - No arn is generated or returned for this resource. * Remove optional name attribute from aws_appautoscaling_target - ScalableTargets do not have a name - I think this was copied from aws_appautoscaling_policy * AWS Application Autoscaling resource documentation tweaks - include a target resource in the policy example - sort attributes by alpha - fixup markdown - add spaces to test config
… fleet. (hashicorp#8697) * provider/aws: Update Application Auto Scaling service model - Add support for automatically scaling an Amazon EC2 Spot fleet. * Remove duplicate policy_type check. * Test creating a scalable target for a splot fleet request. * Test creating a scaling policy for a splot fleet request. * Update resource docs to support scaling an Amazon EC2 Spot fleet. - aws_appautoscaling_policy - aws_appautoscaling_target * Remove arn attribute from aws_appautoscaling_target - No arn is generated or returned for this resource. * Remove optional name attribute from aws_appautoscaling_target - ScalableTargets do not have a name - I think this was copied from aws_appautoscaling_policy * AWS Application Autoscaling resource documentation tweaks - include a target resource in the policy example - sort attributes by alpha - fixup markdown - add spaces to test config
Just for Google-bait in case other people are having the same problem I did with the v0.8.6 patch level release: 0b9fc76 is a backwards-incompatible change that breaks all existing
Just remove the name attribute from your |
Thanks for the note @tysonmote The backwards incompatibilities note in the CHANGELOG should have included the @stack72 |
Just found the |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This was released as part of AWS SDK for Go v1.4.6.
I added tests to create
aws_appautoscaling_policy
andaws_appautoscaling_target
resources using a Spot Fleet Request and they pass, without updating theaws-sdk-go
vendor dependency. Presumably there are no rules enforced to check theScalableDimension
orServiceNamespace
values.QUESTION: Should theaws-sdk-go
vendor dependency be updated tov1.4.6
?TODO:
aws_appautoscaling_target
resouce and docs. There are several copy and paste errors in this resource that should be cleaned up.ALL
TestAccAWSAppautoScaling
tests currently pass in my test account.