-
Notifications
You must be signed in to change notification settings - Fork 20
[to-be-closed] Enable AdoptedResource and add required custom logic for ScalableTarget #42
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| ack_generate_info: | ||
| build_date: "2021-09-10T21:06:37Z" | ||
| build_date: "2021-09-13T17:26:12Z" | ||
| build_hash: a988bddaea3800999e8a548e0e7a4fd44cc00b19 | ||
| go_version: go1.14.14 darwin/amd64 | ||
| version: v0.13.2 | ||
| api_directory_checksum: a13caf20935ebb6193efdee1ab377cae33311ad7 | ||
| api_version: v1alpha1 | ||
| aws_sdk_go_version: v1.37.10 | ||
| generator_config_info: | ||
| file_checksum: 968c7d8481a61c0299fc373cc6d1692a52b55868 | ||
| file_checksum: 56e7824ca9325632a94126f3c1489f45d31e6be6 | ||
| original_file_name: generator.yaml | ||
| last_modification: | ||
| reason: API generation | ||
| timestamp: 2021-09-10 21:06:47.280077 +0000 UTC | ||
| timestamp: 2021-09-13 17:26:20.032123 +0000 UTC |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can rename file to utils.py?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this name is more appropriate since this bootstraps AA resources using boto3 for the tests ? |
||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
| # not use this file except in compliance with the License. A copy of the | ||
| # License is located at | ||
| # | ||
| # http://aws.amazon.com/apache2.0/ | ||
| # | ||
| # or in the "license" file accompanying this file. This file is distributed | ||
| # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| # express or implied. See the License for the specific language governing | ||
| # permissions and limitations under the License. | ||
|
|
||
|
|
||
| import boto3 | ||
|
|
||
| def application_autoscaling_client(): | ||
| return boto3.client("application-autoscaling") | ||
|
|
||
| def sagemaker_endpoint_register_scalable_target(resource_id): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arent these methods specific to the test? why in utills
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can call it something other than utils but this file does for applicationAutoscaling what sagemaker_utils does for sagemaker. These are pre-setup steps for the test and not really related to what we want to test and thus IMO cleaner in a separate module. |
||
| target_input = { | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| "MinCapacity": 1, | ||
| "MaxCapacity": 2, | ||
| } | ||
|
|
||
| target_response = application_autoscaling_client().register_scalable_target(**target_input) | ||
| return target_response | ||
|
|
||
| def sagemaker_endpoint_put_scaling_policy(resource_id, policy_name): | ||
| policy_input = { | ||
| "PolicyName": policy_name, | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| "PolicyType": "TargetTrackingScaling", | ||
| "TargetTrackingScalingPolicyConfiguration": { | ||
| "TargetValue": 70.0, | ||
| "ScaleInCooldown": 700, | ||
| "ScaleOutCooldown": 300, | ||
| "PredefinedMetricSpecification": { | ||
| "PredefinedMetricType": "SageMakerVariantInvocationsPerInstance", | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| policy_response = application_autoscaling_client().put_scaling_policy(**policy_input) | ||
| return policy_response | ||
|
|
||
| def sagemaker_endpoint_deregister_scalable_target(resource_id): | ||
| target_input = { | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| } | ||
|
|
||
| target_response = application_autoscaling_client().deregister_scalable_target(**target_input) | ||
| return target_response | ||
|
|
||
| def sagemaker_endpoint_delete_scaling_policy(resource_id, policy_name): | ||
| policy_input = { | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| "PolicyName": policy_name | ||
| } | ||
|
|
||
| policy_response = application_autoscaling_client().delete_scaling_policy(**policy_input) | ||
| return policy_response | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| apiVersion: services.k8s.aws/v1alpha1 | ||
| kind: AdoptedResource | ||
| metadata: | ||
| name: $ADOPTED_POLICY_NAME | ||
| spec: | ||
| aws: | ||
| nameOrID: $RESOURCE_ID | ||
| additionalKeys: | ||
| serviceNamespace: sagemaker | ||
| kubernetes: | ||
| group: applicationautoscaling.services.k8s.aws | ||
| kind: ScalingPolicy | ||
| metadata: | ||
| name: $ADOPTED_POLICY_NAME |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: services.k8s.aws/v1alpha1 | ||
| kind: AdoptedResource | ||
| metadata: | ||
| name: $ADOPTED_TARGET_NAME | ||
| spec: | ||
| aws: | ||
| nameOrID: $RESOURCE_ID | ||
| additionalKeys: | ||
| serviceNamespace: "sagemaker" | ||
| scalableDimension: "sagemaker:variant:DesiredInstanceCount" | ||
| kubernetes: | ||
| group: applicationautoscaling.services.k8s.aws | ||
| kind: ScalableTarget | ||
| metadata: | ||
| name: $ADOPTED_TARGET_NAME |
Uh oh!
There was an error while loading. Please reload this page.