集群扩容前检查
功能介绍
集群扩容前检查,提前识别子网不足、权限不足等问题导致的扩容失败。
调用方法
请参见如何调用API。
URI
POST /v2/{project_id}/clusters/{cluster_id}/grow-check
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
scale_out |
否 |
ScaleOut object |
参数解释: 扩容/添加空闲节点操作,节点信息请求体。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
create_node_only |
否 |
Boolean |
参数解释: 当前是否仅添加空闲节点。 约束限制: 不涉及。 取值范围: true:仅添加节点,如需扩容则需要单独操作 false:添加节点并扩容集群 默认取值: false |
waiting_for_killing |
否 |
Integer |
参数解释: 自动查杀作业等待时间。 约束限制: guestAgent插件版本8.2.1及以上才支持。 取值范围: 30~1200 默认取值: 0,即不限制。 |
auto_redistribute |
否 |
Boolean |
参数解释: 扩容完成后是否自动启动重分布,默认是。如果设置为false,扩容后不进行重分布,此时集群任务信息处于“待重分布”状态,无法进行其他操作。 约束限制: 不涉及。 取值范围: true:扩容后立即重分布。 false:扩容后不进行重分布,此时集群任务信息处于“待重分布”状态。 默认取值: true |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
data |
Array of GrowCheckResult objects |
参数解释: 扩容前检查信息。 取值范围: 不涉及。 |
note |
NoteInfo object |
参数解释: 扩容前提示信息。 取值范围 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
pass |
Boolean |
参数解释: 检查是否通过,检查通过项默认不展示。 取值范围: true/false |
reason |
String |
参数解释: 检查不通过的原因描述。 取值范围: 不涉及。 |
required |
Boolean |
参数解释: 是否必须检查项。 取值范围:
|
desc |
String |
参数解释: 描述信息。 取值范围: 不涉及。 |
type |
String |
参数解释: 分类。 取值范围: 配额、权限、版本、状态 |
参数 |
参数类型 |
描述 |
---|---|---|
current_dn_num |
Integer |
参数解释: 当前DN数。 取值范围: 不涉及。 |
after_scale_out_dn_num |
Integer |
参数解释: 扩容后DN数。 取值范围: 不涉及。 |
current_bucket_num |
Integer |
参数解释: 当前bucket数。 取值范围: 不涉及。 |
after_scale_out_bucket_num |
Integer |
参数解释: 扩容后bucket数。 取值范围: 不涉及。 |
is_bucket_split |
Boolean |
参数解释: 扩容是否涉及bucket分裂。 取值范围: 不涉及。 |
bucket_tilt_rate |
String |
参数解释: bucket DN倾斜率,用于衡量bucket在DN节点上不均衡程度。 取值范围: 不涉及。 |
after_scale_out_bucket_tilt_rate |
String |
参数解释: 扩容后 bucket DN倾斜率,用于衡量扩容后bucket在DN节点上不均衡程度。 取值范围: 不涉及。 |
请求示例
扩容集群新增3节点,检查是否存在配额或权限等问题。
POST https://{Endpoint}/v2/89cd04f168b84af6be287f71730fdb4b/clusters/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba90/grow-check { "scale_out" : { "count" : 3 } }
响应示例
状态码:200
请求下发成功。
{ "note" : { "bucket_split_info" : { "current_dn_num" : 6, "after_scale_out_bucket_num" : 32, "is_bucket_split" : false, "after_scale_out_dn_num" : 9, "bucket_tilt_rate" : "16.67%", "after_scale_out_bucket_tilt_rate" : "25.00%" } }, "data" : [ { "pass" : false, "reason" : "子网IP超过配额:需要量 3,使用量 249 / 251", "required" : true, "desc" : "子网IP检查", "type" : "配额" } ] }
SDK代码示例
SDK代码示例如下。
扩容集群新增3节点,检查是否存在配额或权限等问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.dws.v2.region.DwsRegion; import com.huaweicloud.sdk.dws.v2.*; import com.huaweicloud.sdk.dws.v2.model.*; public class CheckGrowClusterSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); DwsClient client = DwsClient.newBuilder() .withCredential(auth) .withRegion(DwsRegion.valueOf("<YOUR REGION>")) .build(); CheckGrowClusterRequest request = new CheckGrowClusterRequest(); request.withClusterId("{cluster_id}"); ResizeClusterRequestBody body = new ResizeClusterRequestBody(); ScaleOut scaleOutbody = new ScaleOut(); scaleOutbody.withCount(3); body.withScaleOut(scaleOutbody); request.withBody(body); try { CheckGrowClusterResponse response = client.checkGrowCluster(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
扩容集群新增3节点,检查是否存在配额或权限等问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdws.v2.region.dws_region import DwsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdws.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = DwsClient.new_builder() \ .with_credentials(credentials) \ .with_region(DwsRegion.value_of("<YOUR REGION>")) \ .build() try: request = CheckGrowClusterRequest() request.cluster_id = "{cluster_id}" scaleOutbody = ScaleOut( count=3 ) request.body = ResizeClusterRequestBody( scale_out=scaleOutbody ) response = client.check_grow_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
扩容集群新增3节点,检查是否存在配额或权限等问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := dws.NewDwsClient( dws.DwsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CheckGrowClusterRequest{} request.ClusterId = "{cluster_id}" scaleOutbody := &model.ScaleOut{ Count: int32(3), } request.Body = &model.ResizeClusterRequestBody{ ScaleOut: scaleOutbody, } response, err := client.CheckGrowCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求下发成功。 |
400 |
请求错误。 |
401 |
鉴权失败。 |
403 |
没有操作权限。 |
404 |
找不到资源。 |
500 |
服务内部错误。 |
503 |
服务不可用。 |