華為云計算 云知識 重試集群升級任務RetryUpgradeClusterTask
重試集群升級任務RetryUpgradeClusterTask

 

功能介紹

重新執(zhí)行失敗的集群升級任務。

  • 集群升級涉及多維度的組件升級操作,強烈建議統(tǒng)一通過CCE控制臺執(zhí)行交互式升級,降低集群升級過程的業(yè)務意外受損風險;

  • 當前集群升級相關接口受限開放。

調用方法

請參見如何調用API。

URI

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/operation/upgrade/retry

表1 路徑參數(shù)

參數(shù)

是否必選

參數(shù)類型

描述

project_id

String

項目ID,獲取方式請參見如何獲取接口URI中參數(shù)

cluster_id

String

集群ID,獲取方式請參見如何獲取接口URI中參數(shù)。

請求參數(shù)

響應參數(shù)

請求示例

響應示例

SDK代碼示例

SDK代碼示例如下。

  • Java
  • Python
  • Go
  • 更多
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.cce.v3.region.CceRegion;
import com.huaweicloud.sdk.cce.v3.*;
import com.huaweicloud.sdk.cce.v3.model.*;


public class RetryUpgradeClusterTaskSolution {

    public static void main(String[] args) {
        String ak = "<YOUR AK>";
        String sk = "<YOUR SK>";
        String projectId = "<project_id>";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        CceClient client = CceClient.newBuilder()
                .withCredential(auth)
                .withRegion(CceRegion.valueOf("cn-north-4"))
                .build();
        RetryUpgradeClusterTaskRequest request = new RetryUpgradeClusterTaskRequest();
        request.withClusterId("<cluster_id>");
        try {
            RetryUpgradeClusterTaskResponse response = client.retryUpgradeClusterTask(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());
        }
    }
}
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcce.v3.region.cce_region import CceRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcce.v3 import *

if __name__ == "__main__":
    ak = "<YOUR AK>"
    sk = "<YOUR SK>"
    projectId = "<project_id>"

    credentials = BasicCredentials(ak, sk, projectId) \

    client = CceClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CceRegion.value_of("cn-north-4")) \
        .build()

    try:
        request = RetryUpgradeClusterTaskRequest()
        request.cluster_id = "<cluster_id>"
        response = client.retry_upgrade_cluster_task(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region"
)

func main() {
    ak := "<YOUR AK>"
    sk := "<YOUR SK>"
    projectId := "<project_id>"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := cce.NewCceClient(
        cce.CceClientBuilder().
            WithRegion(region.ValueOf("cn-north-4")).
            WithCredential(auth).
            Build())

    request := &model.RetryUpgradeClusterTaskRequest{}
	request.ClusterId = "<cluster_id>"
	response, err := client.RetryUpgradeClusterTask(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多編程語言的SDK代碼示例,請參見API Explorer的代碼示例頁簽,可生成自動對應的SDK代碼示例。

狀態(tài)碼

狀態(tài)碼

描述

200

表示重試集群升級任務下發(fā)成功。

錯誤碼

請參見錯誤碼