Skip to content

Commit

Permalink
resource/alicloud_cs_autoscaling_config: support scaler_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Joeyzsy authored and ChenHanZhang committed Dec 6, 2024
1 parent 120951c commit 4cbab26
Show file tree
Hide file tree
Showing 10 changed files with 2,324 additions and 372 deletions.
7 changes: 7 additions & 0 deletions alicloud/resource_alicloud_cs_autoscaling_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func resourceAlicloudCSAutoscalingConfig() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"scaler_type": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -168,6 +172,9 @@ func resourceAlicloudCSAutoscalingConfigUpdate(d *schema.ResourceData, meta inte
if v, ok := d.GetOk("scale_up_from_zero"); ok {
updateAutoscalingConfigRequest.ScaleUpFromZero = tea.Bool(v.(bool))
}
if v, ok := d.GetOk("scaler_type"); ok {
updateAutoscalingConfigRequest.ScalerType = tea.String(v.(string))
}
wait := incrementalWait(3*time.Second, 3*time.Second)
err = resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err = client.CreateAutoscalingConfig(tea.String(clusterId), updateAutoscalingConfigRequest)
Expand Down
33 changes: 33 additions & 0 deletions alicloud/resource_alicloud_cs_autoscaling_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,39 @@ func TestAccAliCloudCSAutoscalingConfig_basic(t *testing.T) {
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"cool_down_duration": "5m",
"unneeded_duration": "5m",
"utilization_threshold": "0.6",
"gpu_utilization_threshold": "0.6",
"scan_interval": "40s",
"scale_down_enabled": "false",
"expander": "random",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"cluster_id": CHECKSET,
"cool_down_duration": CHECKSET,
"unneeded_duration": CHECKSET,
"utilization_threshold": CHECKSET,
"gpu_utilization_threshold": CHECKSET,
"scan_interval": CHECKSET,
"scale_down_enabled": CHECKSET,
"expander": CHECKSET,
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"scaler_type": "cluster-autoscaler",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"scaler_type": CHECKSET,
}),
),
},
},
})
}
Expand Down
10 changes: 10 additions & 0 deletions alicloud/service_alicloud_cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,16 @@ func (s *CsClient) CsKubernetesAddonExistRefreshFunc(clusterId string, addonName
return object, object.Status, nil
}
}
func (s *CsClient) DescribeCsAutoscalingConfig(id string) (*client.CreateAutoscalingConfigRequest, error) {
request := &client.CreateAutoscalingConfigRequest{
CoolDownDuration: tea.String("10m"),
UnneededDuration: tea.String("10m"),
UtilizationThreshold: tea.String("0.5"),
GpuUtilizationThreshold: tea.String("0.5"),
ScanInterval: tea.String("30s"),
}
return request, nil
}

func (s *CsClient) installAddon(d *schema.ResourceData) error {
clusterId := d.Get("cluster_id").(string)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/aliyun/terraform-provider-alicloud
require (
github.com/PaesslerAG/jsonpath v0.1.1
github.com/agiledragon/gomonkey/v2 v2.3.1
github.com/alibabacloud-go/cs-20151215/v5 v5.7.9
github.com/alibabacloud-go/cs-20151215/v5 v5.8.1
github.com/alibabacloud-go/tea v1.2.2
github.com/alibabacloud-go/tea-roa v1.3.4
github.com/alibabacloud-go/tea-rpc v1.2.0
Expand Down Expand Up @@ -69,7 +69,7 @@ require (
github.com/alibabacloud-go/darabonba-string v1.0.2 // indirect
github.com/alibabacloud-go/debug v1.0.1 // indirect
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
github.com/alibabacloud-go/openapi-util v0.1.1 // indirect
github.com/alibabacloud-go/tea-oss-utils v1.1.0 // indirect
github.com/alibabacloud-go/tea-roa-utils v1.1.5 // indirect
github.com/alibabacloud-go/tea-rpc-utils v1.1.2 // indirect
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ github.com/alibabacloud-go/alibabacloud-gateway-sls-util v0.0.1/go.mod h1:RApLor
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 h1:zE8vH9C7JiZLNJJQ5OwjU9mSi4T9ef9u3BURT6LCLC8=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5/go.mod h1:tWnyE9AjF8J8qqLk645oUmVUnFybApTQWklQmi5tY6g=
github.com/alibabacloud-go/cs-20151215/v5 v5.7.9 h1:zQdpRgOhpYQVAXfpywnpz3vMxP+bLUoi2QfaFbg3WU4=
github.com/alibabacloud-go/cs-20151215/v5 v5.7.9/go.mod h1:1pR8T0PY7DtF/t+yrOnG2aXj/TRGm1KYK7REaKyvPvM=
github.com/alibabacloud-go/cs-20151215/v5 v5.8.1 h1:X1UIr10L/a2MvLQz1vmbLkXlz3uxe5gB4q71bB6oOd0=
github.com/alibabacloud-go/cs-20151215/v5 v5.8.1/go.mod h1:COcwYmdMKV1vgn7ajJMPohYKEOmXb6GNt+iZVk4IPno=
github.com/alibabacloud-go/darabonba-array v0.1.0 h1:vR8s7b1fWAQIjEjWnuF0JiKsCvclSRTfDzZHTYqfufY=
github.com/alibabacloud-go/darabonba-array v0.1.0/go.mod h1:BLKxr0brnggqOJPqT09DFJ8g3fsDshapUD3C3aOEFaI=
github.com/alibabacloud-go/darabonba-encode-util v0.0.2 h1:1uJGrbsGEVqWcWxrS9MyC2NG0Ax+GpOM5gtupki31XE=
Expand All @@ -271,8 +271,9 @@ github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudH
github.com/alibabacloud-go/fc-open-20210406/v2 v2.0.7 h1:u5y1jiju/oMlFIvyI/xp0M23UUpc6bhtgyQorKFE5ZA=
github.com/alibabacloud-go/fc-open-20210406/v2 v2.0.7/go.mod h1:yd0pDhezz8VYCkzHbLQeJvfyBlQn16JeuS38gS5QveI=
github.com/alibabacloud-go/openapi-util v0.0.11/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
github.com/alibabacloud-go/openapi-util v0.1.0 h1:0z75cIULkDrdEhkLWgi9tnLe+KhAFE/r5Pb3312/eAY=
github.com/alibabacloud-go/openapi-util v0.1.0/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
github.com/alibabacloud-go/openapi-util v0.1.1 h1:ujGErJjG8ncRW6XtBBMphzHTvCxn4DjrVw4m04HsS28=
github.com/alibabacloud-go/openapi-util v0.1.1/go.mod h1:/UehBSE2cf1gYT43GV4E+RxTdLRzURImCYY0aRmlXpw=
github.com/alibabacloud-go/sts-20150401/v2 v2.0.2 h1:sz6ULL9xaAndxpCXtG5fDBD2aF9L/GXyHfDj1hUnaCs=
github.com/alibabacloud-go/sts-20150401/v2 v2.0.2/go.mod h1:JXPMuEvl9zJzUAYffyFMxxXGOUbNdvZYWP6MpJq1658=
github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
Expand Down
Loading

0 comments on commit 4cbab26

Please sign in to comment.