Skip to content

Commit 0208946

Browse files
authored
add network configuration check when creating tke cluster (#2469)
* add network configuration check when creating tke cluster * add changelog 2469.txt * delete mps DescribeTaskDetail
1 parent 14626e3 commit 0208946

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

.changelog/2469.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_cluster: add `cluster_internet` and `cluster_intranet` configuration check
3+
```

tencentcloud/services/mps/service_tencentcloud_mps.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -940,31 +940,6 @@ func (me *MpsService) DeleteMpsEventById(ctx context.Context, eventId string) (e
940940
return
941941
}
942942

943-
func (me *MpsService) DescribeMpsTaskDetailById(ctx context.Context, taskId string) (manageTaskOperation *mps.DescribeTaskDetailResponseParams, errRet error) {
944-
logId := tccommon.GetLogId(ctx)
945-
946-
request := mps.NewDescribeTaskDetailRequest()
947-
request.TaskId = &taskId
948-
949-
defer func() {
950-
if errRet != nil {
951-
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error())
952-
}
953-
}()
954-
955-
ratelimit.Check(request.GetAction())
956-
957-
response, err := me.client.UseMpsClient().DescribeTaskDetail(request)
958-
if err != nil {
959-
errRet = err
960-
return
961-
}
962-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
963-
964-
manageTaskOperation = response.Response
965-
return
966-
}
967-
968943
func (me *MpsService) DeleteMpsOutputById(ctx context.Context, flowId, outputId string) (errRet error) {
969944
logId := tccommon.GetLogId(ctx)
970945

tencentcloud/services/tke/resource_tc_kubernetes_cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,12 @@ func resourceTencentCloudTkeClusterCreate(d *schema.ResourceData, meta interface
15381538
return fmt.Errorf("`cluster_intranet_subnet_id` can only set when `cluster_intranet` is true")
15391539
}
15401540

1541+
_, workerConfigOk := d.GetOk("worker_config")
1542+
if !workerConfigOk && (clusterInternet || clusterIntranet) {
1543+
return fmt.Errorf("when creating a cluster, if `cluster_internet` or `cluster_intranet` is true, " +
1544+
"you need to configure the `worker_config` field to ensure that there are available nodes in the cluster")
1545+
}
1546+
15411547
vpcId := d.Get("vpc_id").(string)
15421548
if vpcId != "" {
15431549
basic.VpcId = vpcId

tencentcloud/services/tke/service_tencentcloud_tke.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ func (me *TkeService) CreateClusterInstances(ctx context.Context,
829829
}
830830

831831
func (me *TkeService) CheckOneOfClusterNodeReady(ctx context.Context, clusterId string, mustHaveWorkers bool) error {
832+
logId := tccommon.GetLogId(ctx)
832833
return resource.Retry(tccommon.ReadRetryTimeout*5, func() *resource.RetryError {
833834
_, workers, err := me.DescribeClusterInstances(ctx, clusterId)
834835
if err != nil {
@@ -843,6 +844,8 @@ func (me *TkeService) CheckOneOfClusterNodeReady(ctx context.Context, clusterId
843844

844845
if len(workers) == 0 && len(virtualNodes) == 0 {
845846
if mustHaveWorkers {
847+
log.Printf("[WARN]%s waiting for workers in the cluster[%s] to be created.\n",
848+
logId, clusterId)
846849
return resource.RetryableError(fmt.Errorf("waiting for workers created"))
847850
}
848851
return nil

0 commit comments

Comments
 (0)