From ae412a790a25edc6826df71e3c1d59cb07ab1548 Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Thu, 1 Dec 2022 10:48:13 +0800 Subject: [PATCH 1/7] feat: When you delete a TKE cluster, disable the cluster audit log, and disable the cluster event log, you can choose whether to delete the audit and event log sets and topics created by default --- go.mod | 4 +- go.sum | 8 ++- .../resource_tc_kubernetes_cluster.go | 45 ++++++++++++-- .../resource_tc_kubernetes_cluster_test.go | 3 + tencentcloud/service_tencentcloud_tke.go | 8 ++- .../tencentcloud/common/http/request.go | 2 +- .../tencentcloud/tke/v20180525/client.go | 42 +++++++++++++ .../tencentcloud/tke/v20180525/errors.go | 12 ++++ .../tencentcloud/tke/v20180525/models.go | 60 +++++++++++++++++-- vendor/modules.txt | 4 +- .../docs/r/kubernetes_cluster.html.markdown | 2 + 11 files changed, 171 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 941aa1aa0a..b90b2a42cd 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.445 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.412 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.546 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.549 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.488 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dayu v1.0.335 @@ -76,7 +76,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.0.268 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.527 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.519 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.515 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 diff --git a/go.sum b/go.sum index 82fabad818..85eff83d06 100644 --- a/go.sum +++ b/go.sum @@ -516,11 +516,13 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.540/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.542 h1:hnKPqiCRTgbAimItdWC4J8TYjzpmdXmiO9AGoj1WjPc= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.542 h1:hnKPqiCRTgbAimItdWC4J8TYjzpmdXmiO9AGoj1WjPc= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.542/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.546 h1:18ZUEkte3A9b5OkF2vAe070HYo3dg0Zonp/rw+GvI8Y= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.546/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.542/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.544 h1:ydXS/Tt3NKxTe10SlnMsyzlHzLOtGJIahvf/CoCVtCM= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.544/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.546 h1:18ZUEkte3A9b5OkF2vAe070HYo3dg0Zonp/rw+GvI8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.546/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.549 h1:j/bk6BVbnhiCU9jIbIQlEwWmLn4FUzEbNPZUC/wKnVo= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.549/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445 h1:Bh7XD0ypNMHYyBOM8hhKsSu+y0VVKUnJVS+YKKhfpGg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.445/go.mod h1:jMDD351efCFpT1+KVFbcpu6SbmP4TYmp4qkoCfr63nQ= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.488 h1:A1seXWtMf2atBjSNYvcwxyDoFzCMgqyVnsxnWzhqJEA= @@ -604,6 +606,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529 h1:vWUgseU github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529/go.mod h1:vOd23iOVeQqm5LSEXUmE8773kiUCwGuoJnTO0po5D+Q= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.519 h1:o8NsQPLV6T8TD4sHxufCwtCsqYM4CUM1132zut6toww= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.519/go.mod h1:ydWSzYKc8AwtT9I8Cd0JdICqiyp9h+u2J5maDWxC9Mo= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549 h1:WWKxOUMmhH5U2VxKtAKp5Hp0RDSxWJUk87pUjI5hmYM= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549/go.mod h1:UPffPhIo23aJ3N40bwWhxhr0fIR9jn0Lfboxh17km8E= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 h1:6Yt74l4pA5QtzhwMNIEUt0spXdSBKH744DDqTHJOCP0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199/go.mod h1:Yw6OQ33z3s4k0HVYTNSffB12qOzEJ2Zf1Vj4+5S3sRs= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.515 h1:OWA3zSqC+tY42DwnlzAZVNYkB5dWgcwk435n+84jXNM= diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index c86aa580e9..4486babe1c 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -1321,6 +1321,12 @@ func resourceTencentCloudTkeCluster() *schema.Resource { Optional: true, Description: "Specify id of existing CLS log topic, or auto create a new topic by leave it empty.", }, + "delete_event_log_and_topic": { + Type: schema.TypeBool, + Optional: true, + Description: "when you want to close the cluster event persistence or delete the cluster, you can use this parameter to determine " + + "whether the event persistence log set and topic created by default will be deleted.", + }, }, }, }, @@ -1346,6 +1352,13 @@ func resourceTencentCloudTkeCluster() *schema.Resource { Optional: true, Description: "Specify id of existing CLS log topic, or auto create a new topic by leave it empty.", }, + "delete_audit_log_and_topic": { + Type: schema.TypeBool, + Optional: true, + Description: "when you want to close the cluster audit log or delete the cluster, you can use " + + "this parameter to determine whether the audit log set and topic created by default will" + + " be deleted.", + }, }, }, }, @@ -2295,7 +2308,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface logSetId := v["log_set_id"].(string) topicId := v["topic_id"].(string) if enabled { - err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled) + err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false) if err != nil { return err } @@ -2307,7 +2320,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface logSetId := v["log_set_id"].(string) topicId := v["topic_id"].(string) if enabled { - err := service.SwitchClusterAudit(ctx, id, logSetId, topicId, enabled) + err := service.SwitchClusterAudit(ctx, id, logSetId, topicId, enabled, false) if err != nil { return err } @@ -2862,12 +2875,14 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface enabled := false logSetId := "" topicId := "" + deleteEventLog := false if ok { enabled = v["enabled"].(bool) logSetId = v["log_set_id"].(string) topicId = v["topic_id"].(string) + deleteEventLog = v["delete_event_log_and_topic"].(bool) } - err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled) + err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog) if err != nil { return err } @@ -2878,12 +2893,14 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface enabled := false logSetId := "" topicId := "" + deleteAuditLog := false if ok { enabled = v["enabled"].(bool) logSetId = v["log_set_id"].(string) topicId = v["topic_id"].(string) + deleteAuditLog = v["delete_audit_log_and_topic"].(bool) } - err := tkeService.SwitchClusterAudit(ctx, id, logSetId, topicId, enabled) + err := tkeService.SwitchClusterAudit(ctx, id, logSetId, topicId, enabled, deleteAuditLog) if err != nil { return err } @@ -2904,6 +2921,26 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface ctx := context.WithValue(context.TODO(), logIdKey, logId) service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn} + if v, ok := helper.InterfacesHeadMap(d, "event_persistence"); ok { + deleteEventLogSetAndTopic := v["delete_event_log_and_topic"].(bool) + if deleteEventLogSetAndTopic { + err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true) + if err != nil { + return err + } + } + } + + if v, ok := helper.InterfacesHeadMap(d, "cluster_audit"); ok { + deleteAuditLogSetAndTopic := v["delete_audit_log_and_topic"].(bool) + if deleteAuditLogSetAndTopic { + err := service.SwitchClusterAudit(ctx, d.Id(), "", "", false, true) + if err != nil { + return err + } + } + } + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { err := service.DeleteCluster(ctx, d.Id()) diff --git a/tencentcloud/resource_tc_kubernetes_cluster_test.go b/tencentcloud/resource_tc_kubernetes_cluster_test.go index d6ab36dcf2..2cee15fb3d 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster_test.go +++ b/tencentcloud/resource_tc_kubernetes_cluster_test.go @@ -132,6 +132,8 @@ func TestAccTencentCloudTkeResourceLogs(t *testing.T) { resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_desc", "test cluster desc"), resource.TestCheckResourceAttr(testTkeClusterResourceKey, "log_agent.0.enabled", "true"), resource.TestCheckResourceAttr(testTkeClusterResourceKey, "event_persistence.0.enabled", "false"), + resource.TestCheckResourceAttr(testTkeClusterResourceKey, "event_persistence.0.delete_audit_log_and_topic", + "true"), resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_audit.0.enabled", "true"), ), }, @@ -477,6 +479,7 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { event_persistence { enabled = false + delete_audit_log_and_topic = true } cluster_audit { diff --git a/tencentcloud/service_tencentcloud_tke.go b/tencentcloud/service_tencentcloud_tke.go index 7236444b16..89e167dde8 100644 --- a/tencentcloud/service_tencentcloud_tke.go +++ b/tencentcloud/service_tencentcloud_tke.go @@ -1593,7 +1593,8 @@ func (me *TkeService) SwitchLogAgent(ctx context.Context, clusterId, rootDir str return me.UninstallLogAgent(ctx, request) } -func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, logSetId, topicId string, enable bool) error { +func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, logSetId, topicId string, + enable, deleteEventLog bool) error { if enable { request := tke.NewEnableEventPersistenceRequest() request.ClusterId = &clusterId @@ -1607,10 +1608,12 @@ func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, log } request := tke.NewDisableEventPersistenceRequest() request.ClusterId = &clusterId + request.DeleteLogSetAndTopic = &deleteEventLog return me.DisableEventPersistence(ctx, request) } -func (me *TkeService) SwitchClusterAudit(ctx context.Context, clusterId, logSetId, topicId string, enable bool) error { +func (me *TkeService) SwitchClusterAudit(ctx context.Context, clusterId, logSetId, topicId string, + enable, deleteAuditLog bool) error { if enable { request := tke.NewEnableClusterAuditRequest() request.ClusterId = &clusterId @@ -1624,6 +1627,7 @@ func (me *TkeService) SwitchClusterAudit(ctx context.Context, clusterId, logSetI } request := tke.NewDisableClusterAuditRequest() request.ClusterId = &clusterId + request.DeleteLogSetAndTopic = &deleteAuditLog return me.DisableClusterAudit(ctx, request) } diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go index fa58a5085a..393a87dda4 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -265,7 +265,7 @@ func CompleteCommonParams(request Request, region string, requestClient string) params["Action"] = request.GetAction() params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) params["Nonce"] = strconv.Itoa(rand.Int()) - params["RequestClient"] = "SDK_GO_1.0.546" + params["RequestClient"] = "SDK_GO_1.0.549" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/client.go index 812c624992..a0de973ff5 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/client.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/client.go @@ -219,6 +219,7 @@ func NewAddExistedInstancesResponse() (response *AddExistedInstancesResponse) { // 可能返回的错误码: // FAILEDOPERATION_CLUSTERNOTFOUND = "FailedOperation.ClusterNotFound" // FAILEDOPERATION_CLUSTERSTATE = "FailedOperation.ClusterState" +// FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" // FAILEDOPERATION_CVMCOMMON = "FailedOperation.CvmCommon" // FAILEDOPERATION_NETWORKSCALEERROR = "FailedOperation.NetworkScaleError" // FAILEDOPERATION_PARAM = "FailedOperation.Param" @@ -245,6 +246,7 @@ func (c *Client) AddExistedInstances(request *AddExistedInstancesRequest) (respo // 可能返回的错误码: // FAILEDOPERATION_CLUSTERNOTFOUND = "FailedOperation.ClusterNotFound" // FAILEDOPERATION_CLUSTERSTATE = "FailedOperation.ClusterState" +// FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" // FAILEDOPERATION_CVMCOMMON = "FailedOperation.CvmCommon" // FAILEDOPERATION_NETWORKSCALEERROR = "FailedOperation.NetworkScaleError" // FAILEDOPERATION_PARAM = "FailedOperation.Param" @@ -647,6 +649,7 @@ func NewCreateClusterResponse() (response *CreateClusterResponse) { // INVALIDPARAMETER_CIDRINVALID = "InvalidParameter.CidrInvalid" // INVALIDPARAMETER_INVALIDPRIVATENETWORKCIDR = "InvalidParameter.InvalidPrivateNetworkCIDR" // LIMITEXCEEDED = "LimitExceeded" +// RESOURCEINSUFFICIENT_SPECIFIEDINSTANCETYPE = "ResourceInsufficient.SpecifiedInstanceType" func (c *Client) CreateCluster(request *CreateClusterRequest) (response *CreateClusterResponse, err error) { return c.CreateClusterWithContext(context.Background(), request) } @@ -717,6 +720,7 @@ func (c *Client) CreateCluster(request *CreateClusterRequest) (response *CreateC // INVALIDPARAMETER_CIDRINVALID = "InvalidParameter.CidrInvalid" // INVALIDPARAMETER_INVALIDPRIVATENETWORKCIDR = "InvalidParameter.InvalidPrivateNetworkCIDR" // LIMITEXCEEDED = "LimitExceeded" +// RESOURCEINSUFFICIENT_SPECIFIEDINSTANCETYPE = "ResourceInsufficient.SpecifiedInstanceType" func (c *Client) CreateClusterWithContext(ctx context.Context, request *CreateClusterRequest) (response *CreateClusterResponse, err error) { if request == nil { request = NewCreateClusterRequest() @@ -961,6 +965,7 @@ func NewCreateClusterInstancesResponse() (response *CreateClusterInstancesRespon // INVALIDPARAMETER = "InvalidParameter" // MISSINGPARAMETER = "MissingParameter" // RESOURCEINUSE = "ResourceInUse" +// RESOURCEINSUFFICIENT_SPECIFIEDINSTANCETYPE = "ResourceInsufficient.SpecifiedInstanceType" // RESOURCENOTFOUND = "ResourceNotFound" // RESOURCEUNAVAILABLE = "ResourceUnavailable" // UNAUTHORIZEDOPERATION = "UnauthorizedOperation" @@ -1008,6 +1013,7 @@ func (c *Client) CreateClusterInstances(request *CreateClusterInstancesRequest) // INVALIDPARAMETER = "InvalidParameter" // MISSINGPARAMETER = "MissingParameter" // RESOURCEINUSE = "ResourceInUse" +// RESOURCEINSUFFICIENT_SPECIFIEDINSTANCETYPE = "ResourceInsufficient.SpecifiedInstanceType" // RESOURCENOTFOUND = "ResourceNotFound" // RESOURCEUNAVAILABLE = "ResourceUnavailable" // UNAUTHORIZEDOPERATION = "UnauthorizedOperation" @@ -1053,6 +1059,7 @@ func NewCreateClusterNodePoolResponse() (response *CreateClusterNodePoolResponse // 可能返回的错误码: // FAILEDOPERATION_ASCOMMON = "FailedOperation.AsCommon" // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR_ASCOMMON = "InternalError.AsCommon" // INTERNALERROR_COMPONENTCLIENTHTTP = "InternalError.ComponentClientHttp" // INTERNALERROR_DB = "InternalError.Db" @@ -1073,6 +1080,7 @@ func (c *Client) CreateClusterNodePool(request *CreateClusterNodePoolRequest) (r // 可能返回的错误码: // FAILEDOPERATION_ASCOMMON = "FailedOperation.AsCommon" // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR_ASCOMMON = "InternalError.AsCommon" // INTERNALERROR_COMPONENTCLIENTHTTP = "InternalError.ComponentClientHttp" // INTERNALERROR_DB = "InternalError.Db" @@ -2063,6 +2071,7 @@ func NewCreatePrometheusRecordRuleYamlResponse() (response *CreatePrometheusReco // 以Yaml的方式创建聚合规则 // // 可能返回的错误码: +// FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" // FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // INTERNALERROR = "InternalError" // INTERNALERROR_PARAM = "InternalError.Param" @@ -2080,6 +2089,7 @@ func (c *Client) CreatePrometheusRecordRuleYaml(request *CreatePrometheusRecordR // 以Yaml的方式创建聚合规则 // // 可能返回的错误码: +// FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" // FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // INTERNALERROR = "InternalError" // INTERNALERROR_PARAM = "InternalError.Param" @@ -2129,6 +2139,7 @@ func NewCreatePrometheusTempResponse() (response *CreatePrometheusTempResponse) // 可能返回的错误码: // INTERNALERROR = "InternalError" // INTERNALERROR_PARAM = "InternalError.Param" +// INTERNALERROR_UNEXPECTEDINTERNAL = "InternalError.UnexpectedInternal" // INVALIDPARAMETER_PARAM = "InvalidParameter.Param" func (c *Client) CreatePrometheusTemp(request *CreatePrometheusTempRequest) (response *CreatePrometheusTempResponse, err error) { return c.CreatePrometheusTempWithContext(context.Background(), request) @@ -2140,6 +2151,7 @@ func (c *Client) CreatePrometheusTemp(request *CreatePrometheusTempRequest) (res // 可能返回的错误码: // INTERNALERROR = "InternalError" // INTERNALERROR_PARAM = "InternalError.Param" +// INTERNALERROR_UNEXPECTEDINTERNAL = "InternalError.UnexpectedInternal" // INVALIDPARAMETER_PARAM = "InvalidParameter.Param" func (c *Client) CreatePrometheusTempWithContext(ctx context.Context, request *CreatePrometheusTempRequest) (response *CreatePrometheusTempResponse, err error) { if request == nil { @@ -2721,6 +2733,7 @@ func NewDeleteClusterNodePoolResponse() (response *DeleteClusterNodePoolResponse // 删除节点池 // // 可能返回的错误码: +// FAILEDOPERATION_RECORDNOTFOUND = "FailedOperation.RecordNotFound" // INTERNALERROR_DB = "InternalError.Db" // INTERNALERROR_DBRECORDNOTFOUND = "InternalError.DbRecordNotFound" // INTERNALERROR_UNEXPECTEDINTERNAL = "InternalError.UnexpectedInternal" @@ -2734,6 +2747,7 @@ func (c *Client) DeleteClusterNodePool(request *DeleteClusterNodePoolRequest) (r // 删除节点池 // // 可能返回的错误码: +// FAILEDOPERATION_RECORDNOTFOUND = "FailedOperation.RecordNotFound" // INTERNALERROR_DB = "InternalError.Db" // INTERNALERROR_DBRECORDNOTFOUND = "InternalError.DbRecordNotFound" // INTERNALERROR_UNEXPECTEDINTERNAL = "InternalError.UnexpectedInternal" @@ -4526,6 +4540,7 @@ func NewDescribeClusterEndpointsResponse() (response *DescribeClusterEndpointsRe // // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" +// FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // FAILEDOPERATION_KUBERNETESCLIENTBUILDERROR = "FailedOperation.KubernetesClientBuildError" // INTERNALERROR = "InternalError" // INTERNALERROR_COMPONENTCLIENTHTTP = "InternalError.ComponentClientHttp" @@ -4545,6 +4560,7 @@ func (c *Client) DescribeClusterEndpoints(request *DescribeClusterEndpointsReque // // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" +// FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // FAILEDOPERATION_KUBERNETESCLIENTBUILDERROR = "FailedOperation.KubernetesClientBuildError" // INTERNALERROR = "InternalError" // INTERNALERROR_COMPONENTCLIENTHTTP = "InternalError.ComponentClientHttp" @@ -4664,6 +4680,7 @@ func NewDescribeClusterKubeconfigResponse() (response *DescribeClusterKubeconfig // // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" +// FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // FAILEDOPERATION_KUBERNETESCLIENTBUILDERROR = "FailedOperation.KubernetesClientBuildError" // INTERNALERROR = "InternalError" // INTERNALERROR_CAMNOAUTH = "InternalError.CamNoAuth" @@ -4692,6 +4709,7 @@ func (c *Client) DescribeClusterKubeconfig(request *DescribeClusterKubeconfigReq // // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" +// FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // FAILEDOPERATION_KUBERNETESCLIENTBUILDERROR = "FailedOperation.KubernetesClientBuildError" // INTERNALERROR = "InternalError" // INTERNALERROR_CAMNOAUTH = "InternalError.CamNoAuth" @@ -5074,6 +5092,7 @@ func NewDescribeClusterSecurityResponse() (response *DescribeClusterSecurityResp // FAILEDOPERATION = "FailedOperation" // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" // FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" +// FAILEDOPERATION_DB = "FailedOperation.Db" // FAILEDOPERATION_DBRECORDNOTFOUND = "FailedOperation.DbRecordNotFound" // FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // FAILEDOPERATION_LBCOMMON = "FailedOperation.LbCommon" @@ -5096,6 +5115,7 @@ func NewDescribeClusterSecurityResponse() (response *DescribeClusterSecurityResp // RESOURCENOTFOUND_CLUSTERNOTFOUND = "ResourceNotFound.ClusterNotFound" // RESOURCENOTFOUND_KUBERESOURCENOTFOUND = "ResourceNotFound.KubeResourceNotFound" // RESOURCEUNAVAILABLE = "ResourceUnavailable" +// RESOURCEUNAVAILABLE_CLUSTERINABNORMALSTAT = "ResourceUnavailable.ClusterInAbnormalStat" // RESOURCEUNAVAILABLE_CLUSTERSTATE = "ResourceUnavailable.ClusterState" // UNAUTHORIZEDOPERATION = "UnauthorizedOperation" // UNAUTHORIZEDOPERATION_CAMNOAUTH = "UnauthorizedOperation.CamNoAuth" @@ -5112,6 +5132,7 @@ func (c *Client) DescribeClusterSecurity(request *DescribeClusterSecurityRequest // FAILEDOPERATION = "FailedOperation" // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" // FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" +// FAILEDOPERATION_DB = "FailedOperation.Db" // FAILEDOPERATION_DBRECORDNOTFOUND = "FailedOperation.DbRecordNotFound" // FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // FAILEDOPERATION_LBCOMMON = "FailedOperation.LbCommon" @@ -5134,6 +5155,7 @@ func (c *Client) DescribeClusterSecurity(request *DescribeClusterSecurityRequest // RESOURCENOTFOUND_CLUSTERNOTFOUND = "ResourceNotFound.ClusterNotFound" // RESOURCENOTFOUND_KUBERESOURCENOTFOUND = "ResourceNotFound.KubeResourceNotFound" // RESOURCEUNAVAILABLE = "ResourceUnavailable" +// RESOURCEUNAVAILABLE_CLUSTERINABNORMALSTAT = "ResourceUnavailable.ClusterInAbnormalStat" // RESOURCEUNAVAILABLE_CLUSTERSTATE = "ResourceUnavailable.ClusterState" // UNAUTHORIZEDOPERATION = "UnauthorizedOperation" // UNAUTHORIZEDOPERATION_CAMNOAUTH = "UnauthorizedOperation.CamNoAuth" @@ -5255,6 +5277,7 @@ func NewDescribeClustersResponse() (response *DescribeClustersResponse) { // 查询集群列表 // // 可能返回的错误码: +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR = "InternalError" // INTERNALERROR_CAMNOAUTH = "InternalError.CamNoAuth" // INTERNALERROR_DB = "InternalError.Db" @@ -5278,6 +5301,7 @@ func (c *Client) DescribeClusters(request *DescribeClustersRequest) (response *D // 查询集群列表 // // 可能返回的错误码: +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR = "InternalError" // INTERNALERROR_CAMNOAUTH = "InternalError.CamNoAuth" // INTERNALERROR_DB = "InternalError.Db" @@ -7280,6 +7304,7 @@ func NewDescribePrometheusOverviewsResponse() (response *DescribePrometheusOverv // // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" +// FAILEDOPERATION_DB = "FailedOperation.Db" // INTERNALERROR = "InternalError" // INTERNALERROR_DB = "InternalError.Db" // INTERNALERROR_PARAM = "InternalError.Param" @@ -7293,6 +7318,7 @@ func (c *Client) DescribePrometheusOverviews(request *DescribePrometheusOverview // // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" +// FAILEDOPERATION_DB = "FailedOperation.Db" // INTERNALERROR = "InternalError" // INTERNALERROR_DB = "InternalError.Db" // INTERNALERROR_PARAM = "InternalError.Param" @@ -7830,6 +7856,7 @@ func NewDescribeRouteTableConflictsResponse() (response *DescribeRouteTableConfl // // 可能返回的错误码: // FAILEDOPERATION_PARAM = "FailedOperation.Param" +// FAILEDOPERATION_VPCRECODRNOTFOUND = "FailedOperation.VpcRecodrNotFound" // INTERNALERROR = "InternalError" // INTERNALERROR_CIDRMASKSIZEOUTOFRANGE = "InternalError.CidrMaskSizeOutOfRange" // INTERNALERROR_INVALIDPRIVATENETWORKCIDR = "InternalError.InvalidPrivateNetworkCidr" @@ -7846,6 +7873,7 @@ func (c *Client) DescribeRouteTableConflicts(request *DescribeRouteTableConflict // // 可能返回的错误码: // FAILEDOPERATION_PARAM = "FailedOperation.Param" +// FAILEDOPERATION_VPCRECODRNOTFOUND = "FailedOperation.VpcRecodrNotFound" // INTERNALERROR = "InternalError" // INTERNALERROR_CIDRMASKSIZEOUTOFRANGE = "InternalError.CidrMaskSizeOutOfRange" // INTERNALERROR_INVALIDPRIVATENETWORKCIDR = "InternalError.InvalidPrivateNetworkCidr" @@ -8621,6 +8649,7 @@ func NewEnableClusterAuditResponse() (response *EnableClusterAuditResponse) { // 开启集群审计 // // 可能返回的错误码: +// FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" // FAILEDOPERATION_CREATECLSINDEX = "FailedOperation.CreateClsIndex" // FAILEDOPERATION_CREATECLSMACHINEGROUP = "FailedOperation.CreateClsMachineGroup" // FAILEDOPERATION_CREATECLSTOPIC = "FailedOperation.CreateClsTopic" @@ -8642,6 +8671,7 @@ func (c *Client) EnableClusterAudit(request *EnableClusterAuditRequest) (respons // 开启集群审计 // // 可能返回的错误码: +// FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" // FAILEDOPERATION_CREATECLSINDEX = "FailedOperation.CreateClsIndex" // FAILEDOPERATION_CREATECLSMACHINEGROUP = "FailedOperation.CreateClsMachineGroup" // FAILEDOPERATION_CREATECLSTOPIC = "FailedOperation.CreateClsTopic" @@ -8748,6 +8778,7 @@ func NewEnableEventPersistenceResponse() (response *EnableEventPersistenceRespon // FAILEDOPERATION = "FailedOperation" // FAILEDOPERATION_CLUSTERNOTFOUND = "FailedOperation.ClusterNotFound" // FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" +// FAILEDOPERATION_CREATECLSCLIENT = "FailedOperation.CreateClsClient" // FAILEDOPERATION_CREATECLSCONFIG = "FailedOperation.CreateClsConfig" // FAILEDOPERATION_CREATECLSINDEX = "FailedOperation.CreateClsIndex" // FAILEDOPERATION_CREATECLSLOGSET = "FailedOperation.CreateClsLogSet" @@ -8778,6 +8809,7 @@ func (c *Client) EnableEventPersistence(request *EnableEventPersistenceRequest) // FAILEDOPERATION = "FailedOperation" // FAILEDOPERATION_CLUSTERNOTFOUND = "FailedOperation.ClusterNotFound" // FAILEDOPERATION_COMPONENTCLIENTUNPACK = "FailedOperation.ComponentClientUnpack" +// FAILEDOPERATION_CREATECLSCLIENT = "FailedOperation.CreateClsClient" // FAILEDOPERATION_CREATECLSCONFIG = "FailedOperation.CreateClsConfig" // FAILEDOPERATION_CREATECLSINDEX = "FailedOperation.CreateClsIndex" // FAILEDOPERATION_CREATECLSLOGSET = "FailedOperation.CreateClsLogSet" @@ -9442,6 +9474,7 @@ func NewModifyClusterAsGroupOptionAttributeResponse() (response *ModifyClusterAs // // 可能返回的错误码: // FAILEDOPERATION_KUBERNETESINTERNAL = "FailedOperation.KubernetesInternal" +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR = "InternalError" // INTERNALERROR_ASCOMMON = "InternalError.AsCommon" // INTERNALERROR_CLUSTERNOTFOUND = "InternalError.ClusterNotFound" @@ -9468,6 +9501,7 @@ func (c *Client) ModifyClusterAsGroupOptionAttribute(request *ModifyClusterAsGro // // 可能返回的错误码: // FAILEDOPERATION_KUBERNETESINTERNAL = "FailedOperation.KubernetesInternal" +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR = "InternalError" // INTERNALERROR_ASCOMMON = "InternalError.AsCommon" // INTERNALERROR_CLUSTERNOTFOUND = "InternalError.ClusterNotFound" @@ -9525,6 +9559,7 @@ func NewModifyClusterAttributeResponse() (response *ModifyClusterAttributeRespon // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" // FAILEDOPERATION_TRADECOMMON = "FailedOperation.TradeCommon" +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR = "InternalError" // INTERNALERROR_CAMNOAUTH = "InternalError.CamNoAuth" // INTERNALERROR_DB = "InternalError.Db" @@ -9550,6 +9585,7 @@ func (c *Client) ModifyClusterAttribute(request *ModifyClusterAttributeRequest) // 可能返回的错误码: // FAILEDOPERATION_COMPONENTCLIENTHTTP = "FailedOperation.ComponentClientHttp" // FAILEDOPERATION_TRADECOMMON = "FailedOperation.TradeCommon" +// FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" // INTERNALERROR = "InternalError" // INTERNALERROR_CAMNOAUTH = "InternalError.CamNoAuth" // INTERNALERROR_DB = "InternalError.Db" @@ -9603,6 +9639,7 @@ func NewModifyClusterAuthenticationOptionsResponse() (response *ModifyClusterAut // 修改集群认证配置 // // 可能返回的错误码: +// FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // INTERNALERROR = "InternalError" // INVALIDPARAMETER = "InvalidParameter" // INVALIDPARAMETER_PARAM = "InvalidParameter.Param" @@ -9616,6 +9653,7 @@ func (c *Client) ModifyClusterAuthenticationOptions(request *ModifyClusterAuthen // 修改集群认证配置 // // 可能返回的错误码: +// FAILEDOPERATION_KUBECOMMON = "FailedOperation.KubeCommon" // INTERNALERROR = "InternalError" // INVALIDPARAMETER = "InvalidParameter" // INVALIDPARAMETER_PARAM = "InvalidParameter.Param" @@ -9807,6 +9845,7 @@ func NewModifyNodePoolDesiredCapacityAboutAsgResponse() (response *ModifyNodePoo // 修改节点池关联伸缩组的期望实例数 // // 可能返回的错误码: +// FAILEDOPERATION_RECORDNOTFOUND = "FailedOperation.RecordNotFound" // INTERNALERROR = "InternalError" // INTERNALERROR_ACCOUNTUSERNOTAUTHENTICATED = "InternalError.AccountUserNotAuthenticated" // INTERNALERROR_DB = "InternalError.Db" @@ -9826,6 +9865,7 @@ func (c *Client) ModifyNodePoolDesiredCapacityAboutAsg(request *ModifyNodePoolDe // 修改节点池关联伸缩组的期望实例数 // // 可能返回的错误码: +// FAILEDOPERATION_RECORDNOTFOUND = "FailedOperation.RecordNotFound" // INTERNALERROR = "InternalError" // INTERNALERROR_ACCOUNTUSERNOTAUTHENTICATED = "InternalError.AccountUserNotAuthenticated" // INTERNALERROR_DB = "InternalError.Db" @@ -10530,6 +10570,7 @@ func NewRunPrometheusInstanceResponse() (response *RunPrometheusInstanceResponse // FAILEDOPERATION_COMPONENTCLIENTCOMMON = "FailedOperation.ComponentClientCommon" // INTERNALERROR_UNEXPECTEDINTERNAL = "InternalError.UnexpectedInternal" // INVALIDPARAMETER_PARAM = "InvalidParameter.Param" +// INVALIDPARAMETER_PROMINSTANCENOTFOUND = "InvalidParameter.PromInstanceNotFound" func (c *Client) RunPrometheusInstance(request *RunPrometheusInstanceRequest) (response *RunPrometheusInstanceResponse, err error) { return c.RunPrometheusInstanceWithContext(context.Background(), request) } @@ -10541,6 +10582,7 @@ func (c *Client) RunPrometheusInstance(request *RunPrometheusInstanceRequest) (r // FAILEDOPERATION_COMPONENTCLIENTCOMMON = "FailedOperation.ComponentClientCommon" // INTERNALERROR_UNEXPECTEDINTERNAL = "InternalError.UnexpectedInternal" // INVALIDPARAMETER_PARAM = "InvalidParameter.Param" +// INVALIDPARAMETER_PROMINSTANCENOTFOUND = "InvalidParameter.PromInstanceNotFound" func (c *Client) RunPrometheusInstanceWithContext(ctx context.Context, request *RunPrometheusInstanceRequest) (response *RunPrometheusInstanceResponse, err error) { if request == nil { request = NewRunPrometheusInstanceRequest() diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/errors.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/errors.go index 155c22b0df..76bcf32c65 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/errors.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/errors.go @@ -59,6 +59,9 @@ const ( // 请求(http请求)其他云服务失败。 FAILEDOPERATION_COMPONENTCLINETHTTP = "FailedOperation.ComponentClinetHttp" + // 创建CLS客户端失败。 + FAILEDOPERATION_CREATECLSCLIENT = "FailedOperation.CreateClsClient" + // 创建CLS采集配置失败。 FAILEDOPERATION_CREATECLSCONFIG = "FailedOperation.CreateClsConfig" @@ -161,12 +164,18 @@ const ( // 子账户RBAC权限不足。 FAILEDOPERATION_RBACFORBIDDEN = "FailedOperation.RBACForbidden" + // 记录没有发现。 + FAILEDOPERATION_RECORDNOTFOUND = "FailedOperation.RecordNotFound" + // 已有相同任务执行中。 FAILEDOPERATION_TASKALREADYRUNNING = "FailedOperation.TaskAlreadyRunning" // 询价错误。 FAILEDOPERATION_TRADECOMMON = "FailedOperation.TradeCommon" + // 不可预知的错误。 + FAILEDOPERATION_UNEXPECTEDERROR = "FailedOperation.UnexpectedError" + // VPC未知错误。 FAILEDOPERATION_VPCUNEXPECTEDERROR = "FailedOperation.VPCUnexpectedError" @@ -464,6 +473,9 @@ const ( // 资源不足。 RESOURCEINSUFFICIENT = "ResourceInsufficient" + // CVM资源不足。 + RESOURCEINSUFFICIENT_SPECIFIEDINSTANCETYPE = "ResourceInsufficient.SpecifiedInstanceType" + // 资源不存在。 RESOURCENOTFOUND = "ResourceNotFound" diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/models.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/models.go index 59c40c5d1d..347f9630a5 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/models.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/models.go @@ -908,7 +908,7 @@ type ClusterAsGroupOption struct { } type ClusterBasicSettings struct { - // 集群操作系统,支持设置公共镜像(字段传相应镜像ID)和自定义镜像(字段传相应镜像Name),详情参考:https://cloud.tencent.com/document/product/457/68289 + // 集群操作系统,支持设置公共镜像(字段传相应镜像Name)和自定义镜像(字段传相应镜像ID),详情参考:https://cloud.tencent.com/document/product/457/68289 ClusterOs *string `json:"ClusterOs,omitempty" name:"ClusterOs"` // 集群版本,默认值为1.10.5 @@ -1596,10 +1596,10 @@ type CreateClusterNodePoolRequestParams struct { // cluster id ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` - // AutoScalingGroupPara AS组参数 + // AutoScalingGroupPara AS组参数,参考 https://cloud.tencent.com/document/product/377/20440 AutoScalingGroupPara *string `json:"AutoScalingGroupPara,omitempty" name:"AutoScalingGroupPara"` - // LaunchConfigurePara 运行参数 + // LaunchConfigurePara 运行参数,参考 https://cloud.tencent.com/document/product/377/20447 LaunchConfigurePara *string `json:"LaunchConfigurePara,omitempty" name:"LaunchConfigurePara"` // InstanceAdvancedSettings 示例参数 @@ -1642,10 +1642,10 @@ type CreateClusterNodePoolRequest struct { // cluster id ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` - // AutoScalingGroupPara AS组参数 + // AutoScalingGroupPara AS组参数,参考 https://cloud.tencent.com/document/product/377/20440 AutoScalingGroupPara *string `json:"AutoScalingGroupPara,omitempty" name:"AutoScalingGroupPara"` - // LaunchConfigurePara 运行参数 + // LaunchConfigurePara 运行参数,参考 https://cloud.tencent.com/document/product/377/20447 LaunchConfigurePara *string `json:"LaunchConfigurePara,omitempty" name:"LaunchConfigurePara"` // InstanceAdvancedSettings 示例参数 @@ -10174,6 +10174,9 @@ func (r *DescribeVpcCniPodLimitsResponse) FromJsonString(s string) error { type DisableClusterAuditRequestParams struct { // 集群ID ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 取值为true代表关闭集群审计时删除默认创建的日志集和主题,false代表不删除 + DeleteLogSetAndTopic *bool `json:"DeleteLogSetAndTopic,omitempty" name:"DeleteLogSetAndTopic"` } type DisableClusterAuditRequest struct { @@ -10181,6 +10184,9 @@ type DisableClusterAuditRequest struct { // 集群ID ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 取值为true代表关闭集群审计时删除默认创建的日志集和主题,false代表不删除 + DeleteLogSetAndTopic *bool `json:"DeleteLogSetAndTopic,omitempty" name:"DeleteLogSetAndTopic"` } func (r *DisableClusterAuditRequest) ToJsonString() string { @@ -10196,6 +10202,7 @@ func (r *DisableClusterAuditRequest) FromJsonString(s string) error { return err } delete(f, "ClusterId") + delete(f, "DeleteLogSetAndTopic") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DisableClusterAuditRequest has unknown keys!", "") } @@ -10282,6 +10289,9 @@ func (r *DisableClusterDeletionProtectionResponse) FromJsonString(s string) erro type DisableEventPersistenceRequestParams struct { // 集群ID ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 取值为true代表关闭集群审计时删除默认创建的日志集和主题,false代表不删除 + DeleteLogSetAndTopic *bool `json:"DeleteLogSetAndTopic,omitempty" name:"DeleteLogSetAndTopic"` } type DisableEventPersistenceRequest struct { @@ -10289,6 +10299,9 @@ type DisableEventPersistenceRequest struct { // 集群ID ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"` + + // 取值为true代表关闭集群审计时删除默认创建的日志集和主题,false代表不删除 + DeleteLogSetAndTopic *bool `json:"DeleteLogSetAndTopic,omitempty" name:"DeleteLogSetAndTopic"` } func (r *DisableEventPersistenceRequest) ToJsonString() string { @@ -10304,6 +10317,7 @@ func (r *DisableEventPersistenceRequest) FromJsonString(s string) error { return err } delete(f, "ClusterId") + delete(f, "DeleteLogSetAndTopic") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DisableEventPersistenceRequest has unknown keys!", "") } @@ -11020,7 +11034,7 @@ type EnhancedService struct { // 开启云监控服务。若不指定该参数,则默认开启云监控服务。 MonitorService *RunMonitorServiceEnabled `json:"MonitorService,omitempty" name:"MonitorService"` - // 开启云自动化助手服务。若不指定该参数,则默认不开启云自动化助手服务。 + // 开启云自动化助手服务(TencentCloud Automation Tools,TAT)。若不指定该参数,则公共镜像默认开启云自动化助手服务,其他镜像默认不开启云自动化助手服务。 AutomationService *RunAutomationServiceEnabled `json:"AutomationService,omitempty" name:"AutomationService"` } @@ -12537,6 +12551,15 @@ type ModifyClusterNodePoolRequestParams struct { // 镜像版本,"DOCKER_CUSTOMIZE"(容器定制版),"GENERAL"(普通版本,默认值) OsCustomizeType *string `json:"OsCustomizeType,omitempty" name:"OsCustomizeType"` + // GPU驱动版本,CUDA版本,cuDNN版本以及是否启用MIG特性 + GPUArgs *GPUArgs `json:"GPUArgs,omitempty" name:"GPUArgs"` + + // base64编码后的自定义脚本 + UserScript *string `json:"UserScript,omitempty" name:"UserScript"` + + // 更新label和taint时忽略存量节点 + IgnoreExistedNode *bool `json:"IgnoreExistedNode,omitempty" name:"IgnoreExistedNode"` + // 节点自定义参数 ExtraArgs *InstanceExtraArgs `json:"ExtraArgs,omitempty" name:"ExtraArgs"` @@ -12548,6 +12571,9 @@ type ModifyClusterNodePoolRequestParams struct { // 删除保护开关 DeletionProtection *bool `json:"DeletionProtection,omitempty" name:"DeletionProtection"` + + // dockerd --graph 指定值, 默认为 /var/lib/docker + DockerGraphPath *string `json:"DockerGraphPath,omitempty" name:"DockerGraphPath"` } type ModifyClusterNodePoolRequest struct { @@ -12583,6 +12609,15 @@ type ModifyClusterNodePoolRequest struct { // 镜像版本,"DOCKER_CUSTOMIZE"(容器定制版),"GENERAL"(普通版本,默认值) OsCustomizeType *string `json:"OsCustomizeType,omitempty" name:"OsCustomizeType"` + // GPU驱动版本,CUDA版本,cuDNN版本以及是否启用MIG特性 + GPUArgs *GPUArgs `json:"GPUArgs,omitempty" name:"GPUArgs"` + + // base64编码后的自定义脚本 + UserScript *string `json:"UserScript,omitempty" name:"UserScript"` + + // 更新label和taint时忽略存量节点 + IgnoreExistedNode *bool `json:"IgnoreExistedNode,omitempty" name:"IgnoreExistedNode"` + // 节点自定义参数 ExtraArgs *InstanceExtraArgs `json:"ExtraArgs,omitempty" name:"ExtraArgs"` @@ -12594,6 +12629,9 @@ type ModifyClusterNodePoolRequest struct { // 删除保护开关 DeletionProtection *bool `json:"DeletionProtection,omitempty" name:"DeletionProtection"` + + // dockerd --graph 指定值, 默认为 /var/lib/docker + DockerGraphPath *string `json:"DockerGraphPath,omitempty" name:"DockerGraphPath"` } func (r *ModifyClusterNodePoolRequest) ToJsonString() string { @@ -12618,10 +12656,14 @@ func (r *ModifyClusterNodePoolRequest) FromJsonString(s string) error { delete(f, "EnableAutoscale") delete(f, "OsName") delete(f, "OsCustomizeType") + delete(f, "GPUArgs") + delete(f, "UserScript") + delete(f, "IgnoreExistedNode") delete(f, "ExtraArgs") delete(f, "Tags") delete(f, "Unschedulable") delete(f, "DeletionProtection") + delete(f, "DockerGraphPath") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "ModifyClusterNodePoolRequest has unknown keys!", "") } @@ -14779,6 +14821,12 @@ type SubnetInfos struct { // 安全组id SecurityGroups []*string `json:"SecurityGroups,omitempty" name:"SecurityGroups"` + + // 系统 + Os *string `json:"Os,omitempty" name:"Os"` + + // 硬件架构 + Arch *string `json:"Arch,omitempty" name:"Arch"` } // Predefined struct for user diff --git a/vendor/modules.txt b/vendor/modules.txt index 7d08c66d87..26b885a243 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -559,7 +559,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.412 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.546 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.549 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http @@ -645,7 +645,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq/v20200217 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem/v20210701 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.529 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.519 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.549 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20180717 diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 4d2f1ab3a7..3de399f817 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -497,6 +497,7 @@ The `auth_options` object supports the following: The `cluster_audit` object supports the following: * `enabled` - (Required, Bool) Specify weather the Cluster Audit enabled. NOTE: Enable Cluster Audit will also auto install Log Agent. +* `delete_audit_log_and_topic` - (Optional, Bool) when you want to close the cluster audit log or delete the cluster, you can use this parameter to determine whether the audit log set and topic created by default will be deleted. * `log_set_id` - (Optional, String) Specify id of existing CLS log set, or auto create a new set by leave it empty. * `topic_id` - (Optional, String) Specify id of existing CLS log topic, or auto create a new topic by leave it empty. @@ -521,6 +522,7 @@ The `data_disk` object supports the following: The `event_persistence` object supports the following: * `enabled` - (Required, Bool) Specify weather the Event Persistence enabled. +* `delete_event_log_and_topic` - (Optional, Bool) when you want to close the cluster event persistence or delete the cluster, you can use this parameter to determine whether the event persistence log set and topic created by default will be deleted. * `log_set_id` - (Optional, String) Specify id of existing CLS log set, or auto create a new set by leave it empty. * `topic_id` - (Optional, String) Specify id of existing CLS log topic, or auto create a new topic by leave it empty. From 1b05743b987d00111ea711103f74ebfe0e302029 Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Thu, 1 Dec 2022 18:21:45 +0800 Subject: [PATCH 2/7] fix:TKE cluster event persistence cannot be disabled twice --- tencentcloud/internal/helper/helper.go | 12 ++++++++++++ tencentcloud/resource_tc_kubernetes_cluster.go | 7 ++++--- tencentcloud/service_tencentcloud_tke.go | 9 ++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tencentcloud/internal/helper/helper.go b/tencentcloud/internal/helper/helper.go index b310d51e91..4b5855e7ca 100644 --- a/tencentcloud/internal/helper/helper.go +++ b/tencentcloud/internal/helper/helper.go @@ -146,6 +146,18 @@ func InterfacesHeadMap(d *schema.ResourceData, key string) (result map[string]in return } +// ConvertInterfacesHeadToMap returns string key map if argument is MaxItem: 1 List Type +func ConvertInterfacesHeadToMap(v interface{}) (result map[string]interface{}, ok bool) { + interfaces, ok := v.([]interface{}) + if !ok || len(interfaces) == 0 { + ok = false + return + } + head := interfaces[0] + result, ok = head.(map[string]interface{}) + return +} + func SetMapInterfaces(d *schema.ResourceData, key string, values ...map[string]interface{}) error { val := make([]interface{}, 0, len(values)) for i := range values { diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index 4486babe1c..93df50be11 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -2308,7 +2308,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface logSetId := v["log_set_id"].(string) topicId := v["topic_id"].(string) if enabled { - err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false) + err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false,d) if err != nil { return err } @@ -2882,7 +2882,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface topicId = v["topic_id"].(string) deleteEventLog = v["delete_event_log_and_topic"].(bool) } - err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog) + err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog, d) if err != nil { return err } @@ -2900,6 +2900,7 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface topicId = v["topic_id"].(string) deleteAuditLog = v["delete_audit_log_and_topic"].(bool) } + err := tkeService.SwitchClusterAudit(ctx, id, logSetId, topicId, enabled, deleteAuditLog) if err != nil { return err @@ -2924,7 +2925,7 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface if v, ok := helper.InterfacesHeadMap(d, "event_persistence"); ok { deleteEventLogSetAndTopic := v["delete_event_log_and_topic"].(bool) if deleteEventLogSetAndTopic { - err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true) + err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true,d) if err != nil { return err } diff --git a/tencentcloud/service_tencentcloud_tke.go b/tencentcloud/service_tencentcloud_tke.go index 89e167dde8..64f4949f88 100644 --- a/tencentcloud/service_tencentcloud_tke.go +++ b/tencentcloud/service_tencentcloud_tke.go @@ -1594,7 +1594,7 @@ func (me *TkeService) SwitchLogAgent(ctx context.Context, clusterId, rootDir str } func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, logSetId, topicId string, - enable, deleteEventLog bool) error { + enable, deleteEventLog bool,d *schema.ResourceData) error { if enable { request := tke.NewEnableEventPersistenceRequest() request.ClusterId = &clusterId @@ -1606,6 +1606,13 @@ func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, log } return me.EnableEventPersistence(ctx, request) } + if !enable { + oldConf, _ := d.GetChange("event_persistence") + oldEventConfigMap, ok := helper.ConvertInterfacesHeadToMap(oldConf) + if ok && oldEventConfigMap["enabled"].(bool) == false { + return nil + } + } request := tke.NewDisableEventPersistenceRequest() request.ClusterId = &clusterId request.DeleteLogSetAndTopic = &deleteEventLog From 57d80aedec37ba37f317295b3b657782fc363ac3 Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Thu, 1 Dec 2022 19:25:26 +0800 Subject: [PATCH 3/7] fix:formatting code --- tencentcloud/resource_tc_kubernetes_cluster.go | 4 ++-- tencentcloud/service_tencentcloud_tke.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index 93df50be11..bb53ddf514 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -2308,7 +2308,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface logSetId := v["log_set_id"].(string) topicId := v["topic_id"].(string) if enabled { - err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false,d) + err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false, d) if err != nil { return err } @@ -2925,7 +2925,7 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface if v, ok := helper.InterfacesHeadMap(d, "event_persistence"); ok { deleteEventLogSetAndTopic := v["delete_event_log_and_topic"].(bool) if deleteEventLogSetAndTopic { - err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true,d) + err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true, d) if err != nil { return err } diff --git a/tencentcloud/service_tencentcloud_tke.go b/tencentcloud/service_tencentcloud_tke.go index 64f4949f88..2b060198fe 100644 --- a/tencentcloud/service_tencentcloud_tke.go +++ b/tencentcloud/service_tencentcloud_tke.go @@ -1594,7 +1594,7 @@ func (me *TkeService) SwitchLogAgent(ctx context.Context, clusterId, rootDir str } func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, logSetId, topicId string, - enable, deleteEventLog bool,d *schema.ResourceData) error { + enable, deleteEventLog bool, d *schema.ResourceData) error { if enable { request := tke.NewEnableEventPersistenceRequest() request.ClusterId = &clusterId From 584a39460d6a28c75f0f6b6996c9d396c737687e Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Thu, 1 Dec 2022 20:22:05 +0800 Subject: [PATCH 4/7] fix:added error retry logic for deleting tke cluster audit logs and deleting tke cluster event persistence logs --- .../resource_tc_kubernetes_cluster.go | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index bb53ddf514..92686533da 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -2921,28 +2921,30 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface logId := getLogId(contextNil) ctx := context.WithValue(context.TODO(), logIdKey, logId) service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn} - + deleteEventLogSetAndTopic := false + deleteAuditLogSetAndTopic := false if v, ok := helper.InterfacesHeadMap(d, "event_persistence"); ok { - deleteEventLogSetAndTopic := v["delete_event_log_and_topic"].(bool) + deleteEventLogSetAndTopic = v["delete_event_log_and_topic"].(bool) + } + + if v, ok := helper.InterfacesHeadMap(d, "cluster_audit"); ok { + deleteAuditLogSetAndTopic = v["delete_audit_log_and_topic"].(bool) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { if deleteEventLogSetAndTopic { - err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true, d) + err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, + true, d) if err != nil { - return err + return retryError(err, InternalError) } } - } - - if v, ok := helper.InterfacesHeadMap(d, "cluster_audit"); ok { - deleteAuditLogSetAndTopic := v["delete_audit_log_and_topic"].(bool) if deleteAuditLogSetAndTopic { err := service.SwitchClusterAudit(ctx, d.Id(), "", "", false, true) if err != nil { - return err + return retryError(err, InternalError) } } - } - - err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { err := service.DeleteCluster(ctx, d.Id()) if e, ok := err.(*errors.TencentCloudSDKError); ok { From 486ac06c7b179e3d39b2e45ec908fcdfad8e7117 Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Fri, 2 Dec 2022 18:21:51 +0800 Subject: [PATCH 5/7] fix:When deleting a cluster, you do not need to determine whether the enable value of the cluster persistence log is modified --- .../resource_tc_kubernetes_cluster.go | 37 +++++++++++++++---- tencentcloud/service_tencentcloud_tke.go | 10 +---- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index 92686533da..c4fac6d5fc 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -2308,7 +2308,7 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface logSetId := v["log_set_id"].(string) topicId := v["topic_id"].(string) if enabled { - err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false, d) + err := service.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, false) if err != nil { return err } @@ -2876,16 +2876,27 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface logSetId := "" topicId := "" deleteEventLog := false + deleteEventLogFlag := true if ok { enabled = v["enabled"].(bool) logSetId = v["log_set_id"].(string) topicId = v["topic_id"].(string) deleteEventLog = v["delete_event_log_and_topic"].(bool) } - err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog, d) - if err != nil { - return err + if !enabled { + oldConf, _ := d.GetChange("event_persistence") + oldEventConf, ok := helper.ConvertInterfacesHeadToMap(oldConf) + if ok && !oldEventConf["enabled"].(bool) { + deleteEventLogFlag = false + } + } + if deleteEventLogFlag { + err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog) + if err != nil { + return err + } } + } if d.HasChange("cluster_audit") { @@ -2922,9 +2933,12 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface ctx := context.WithValue(context.TODO(), logIdKey, logId) service := TkeService{client: meta.(*TencentCloudClient).apiV3Conn} deleteEventLogSetAndTopic := false + enableEventLog := false deleteAuditLogSetAndTopic := false if v, ok := helper.InterfacesHeadMap(d, "event_persistence"); ok { deleteEventLogSetAndTopic = v["delete_event_log_and_topic"].(bool) + // get cluster current enabled status + enableEventLog = v["enabled"].(bool) } if v, ok := helper.InterfacesHeadMap(d, "cluster_audit"); ok { @@ -2932,15 +2946,24 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface } err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { - if deleteEventLogSetAndTopic { - err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, - true, d) + if deleteEventLogSetAndTopic && enableEventLog { + err := service.SwitchEventPersistence(ctx, d.Id(), "", "", false, true) + if e, ok := err.(*errors.TencentCloudSDKError); ok { + if e.GetCode() != "FailedOperation.ClusterNotFound" { + return retryError(err, InternalError) + } + } if err != nil { return retryError(err, InternalError) } } if deleteAuditLogSetAndTopic { err := service.SwitchClusterAudit(ctx, d.Id(), "", "", false, true) + if e, ok := err.(*errors.TencentCloudSDKError); ok { + if e.GetCode() != "ResourceNotFound.ClusterNotFound" { + return retryError(err, InternalError) + } + } if err != nil { return retryError(err, InternalError) } diff --git a/tencentcloud/service_tencentcloud_tke.go b/tencentcloud/service_tencentcloud_tke.go index 2b060198fe..f95095b78b 100644 --- a/tencentcloud/service_tencentcloud_tke.go +++ b/tencentcloud/service_tencentcloud_tke.go @@ -1594,7 +1594,7 @@ func (me *TkeService) SwitchLogAgent(ctx context.Context, clusterId, rootDir str } func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, logSetId, topicId string, - enable, deleteEventLog bool, d *schema.ResourceData) error { + enable, deleteEventLog bool) error { if enable { request := tke.NewEnableEventPersistenceRequest() request.ClusterId = &clusterId @@ -1606,13 +1606,7 @@ func (me *TkeService) SwitchEventPersistence(ctx context.Context, clusterId, log } return me.EnableEventPersistence(ctx, request) } - if !enable { - oldConf, _ := d.GetChange("event_persistence") - oldEventConfigMap, ok := helper.ConvertInterfacesHeadToMap(oldConf) - if ok && oldEventConfigMap["enabled"].(bool) == false { - return nil - } - } + request := tke.NewDisableEventPersistenceRequest() request.ClusterId = &clusterId request.DeleteLogSetAndTopic = &deleteEventLog From b7a86bb23a95a9fa53817636c5eabe6add07d891 Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Tue, 6 Dec 2022 10:48:34 +0800 Subject: [PATCH 6/7] supplementary unit tests for removing audit logs and event persistence logs for the tke cluster --- tencentcloud/resource_tc_kubernetes_cluster.go | 6 ++---- tencentcloud/resource_tc_kubernetes_cluster_test.go | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index c4fac6d5fc..4433f10470 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -2952,8 +2952,7 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface if e.GetCode() != "FailedOperation.ClusterNotFound" { return retryError(err, InternalError) } - } - if err != nil { + } else if err != nil { return retryError(err, InternalError) } } @@ -2963,8 +2962,7 @@ func resourceTencentCloudTkeClusterDelete(d *schema.ResourceData, meta interface if e.GetCode() != "ResourceNotFound.ClusterNotFound" { return retryError(err, InternalError) } - } - if err != nil { + } else if err != nil { return retryError(err, InternalError) } } diff --git a/tencentcloud/resource_tc_kubernetes_cluster_test.go b/tencentcloud/resource_tc_kubernetes_cluster_test.go index 2cee15fb3d..916f6f4287 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster_test.go +++ b/tencentcloud/resource_tc_kubernetes_cluster_test.go @@ -56,6 +56,7 @@ func TestAccTencentCloudTkeResourceBasic(t *testing.T) { CheckDestroy: testAccCheckTkeDestroy, Steps: []resource.TestStep{ { + //PreventDiskCleanup: true, Config: testAccTkeCluster, Check: resource.ComposeTestCheckFunc( testAccCheckTkeExists(testTkeClusterResourceKey), @@ -108,6 +109,7 @@ func TestAccTencentCloudTkeResourceLogs(t *testing.T) { CheckDestroy: testAccCheckTkeDestroy, Steps: []resource.TestStep{ { + //PreventDiskCleanup: true, Config: testAccTkeClusterLogs, Check: resource.ComposeTestCheckFunc( testAccCheckTkeExists(testTkeClusterResourceKey), @@ -132,9 +134,11 @@ func TestAccTencentCloudTkeResourceLogs(t *testing.T) { resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_desc", "test cluster desc"), resource.TestCheckResourceAttr(testTkeClusterResourceKey, "log_agent.0.enabled", "true"), resource.TestCheckResourceAttr(testTkeClusterResourceKey, "event_persistence.0.enabled", "false"), - resource.TestCheckResourceAttr(testTkeClusterResourceKey, "event_persistence.0.delete_audit_log_and_topic", + resource.TestCheckResourceAttr(testTkeClusterResourceKey, "event_persistence.0.delete_event_log_and_topic", "true"), resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_audit.0.enabled", "true"), + resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_audit.0.delete_audit_log_and_topic", + "true"), ), }, }, @@ -479,10 +483,11 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { event_persistence { enabled = false - delete_audit_log_and_topic = true + delete_event_log_and_topic = true } cluster_audit { enabled = true + delete_audit_log_and_topic = true } }` From ec1977ff9a2de353765f16ee3b3dbf5037ccd002 Mon Sep 17 00:00:00 2001 From: bobklxiao Date: Tue, 6 Dec 2022 20:00:21 +0800 Subject: [PATCH 7/7] instead of getChange, use getKey to get the current status --- tencentcloud/resource_tc_kubernetes_cluster.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index 4433f10470..651e9f748c 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -2876,27 +2876,17 @@ func resourceTencentCloudTkeClusterUpdate(d *schema.ResourceData, meta interface logSetId := "" topicId := "" deleteEventLog := false - deleteEventLogFlag := true if ok { enabled = v["enabled"].(bool) logSetId = v["log_set_id"].(string) topicId = v["topic_id"].(string) deleteEventLog = v["delete_event_log_and_topic"].(bool) } - if !enabled { - oldConf, _ := d.GetChange("event_persistence") - oldEventConf, ok := helper.ConvertInterfacesHeadToMap(oldConf) - if ok && !oldEventConf["enabled"].(bool) { - deleteEventLogFlag = false - } - } - if deleteEventLogFlag { - err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog) - if err != nil { - return err - } - } + err := tkeService.SwitchEventPersistence(ctx, id, logSetId, topicId, enabled, deleteEventLog) + if err != nil { + return err + } } if d.HasChange("cluster_audit") {