6
6
"log"
7
7
"strings"
8
8
9
+ tchttp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http"
10
+
9
11
as "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as/v20180419"
10
12
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
11
13
@@ -616,48 +618,94 @@ func resourceTencentCloudKubernetesNodePoolUpdateOnStart(ctx context.Context) er
616
618
"labels" ,
617
619
"tags" ,
618
620
) {
619
- request := tke .NewModifyClusterNodePoolRequest ()
620
- request .ClusterId = & clusterId
621
- request .NodePoolId = & nodePoolId
621
+ var body map [string ]interface {}
622
+ nodeOs := d .Get ("node_os" ).(string )
623
+ nodeOsType := d .Get ("node_os_type" ).(string )
624
+ //自定镜像不能指定节点操作系统类型
625
+ if strings .Contains (nodeOs , "img-" ) {
626
+ nodeOsType = ""
627
+ }
622
628
623
629
labels := GetTkeLabels (d , "labels" )
624
- tags := helper .GetTags (d , "tags" )
625
- if len (labels ) > 0 {
626
- request .Labels = labels
630
+ body = map [string ]interface {}{
631
+ "ClusterId" : clusterId ,
632
+ "NodePoolId" : nodePoolId ,
633
+ "OsName" : nodeOs ,
634
+ "OsCustomizeType" : nodeOsType ,
635
+ "Labels" : labels ,
627
636
}
637
+
638
+ tags := helper .GetTags (d , "tags" )
628
639
if len (tags ) > 0 {
640
+ var tmpTags []* tke.Tag
629
641
for k , v := range tags {
630
642
key := k
631
643
val := v
632
- request . Tags = append (request . Tags , & tke.Tag {
644
+ tmpTags = append (tmpTags , & tke.Tag {
633
645
Key : & key ,
634
646
Value : & val ,
635
647
})
636
648
}
649
+
650
+ body ["Tags" ] = tmpTags
637
651
}
638
652
639
- nodeOs := d . Get ( "node_os" ).( string )
640
- nodeOsType := d . Get ( "node_os_type" ).( string )
641
- //自定镜像不能指定节点操作系统类型
642
- if strings . Contains ( nodeOs , "img-" ) {
643
- nodeOsType = ""
653
+ client := meta .(tccommon. ProviderMeta ). GetAPIV3Conn (). UseOmitNilClient ( "tke" )
654
+ request := tchttp . NewCommonRequest ( "tke" , "2018-05-25" , "ModifyClusterNodePool" )
655
+ err := request . SetActionParameters ( body )
656
+ if err != nil {
657
+ return err
644
658
}
645
- request .OsName = & nodeOs
646
- request .OsCustomizeType = & nodeOsType
647
- err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
648
- result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseTkeClient ().ModifyClusterNodePool (request )
649
- if e != nil {
650
- return tccommon .RetryError (e )
651
- } else {
652
- log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
653
- }
654
- return nil
655
- })
659
+
660
+ response := tchttp .NewCommonResponse ()
661
+ err = client .Send (request , response )
656
662
if err != nil {
657
- log .Printf ("[CRITAL]%s update kubernetes node pool failed, reason:%+v" , logId , err )
663
+ fmt .Printf ("update kubernetes node pool taints failed: %v \n " , err )
658
664
return err
659
665
}
660
666
667
+ //request := tke.NewModifyClusterNodePoolRequest()
668
+ //request.ClusterId = &clusterId
669
+ //request.NodePoolId = &nodePoolId
670
+ //nodeOs := d.Get("node_os").(string)
671
+ //nodeOsType := d.Get("node_os_type").(string)
672
+ ////自定镜像不能指定节点操作系统类型
673
+ //if strings.Contains(nodeOs, "img-") {
674
+ // nodeOsType = ""
675
+ //}
676
+ //request.OsName = &nodeOs
677
+ //request.OsCustomizeType = &nodeOsType
678
+ //
679
+ //labels := GetTkeLabels(d, "labels")
680
+ //tags := helper.GetTags(d, "tags")
681
+ //if len(labels) > 0 {
682
+ // request.Labels = labels
683
+ //}
684
+ //if len(tags) > 0 {
685
+ // for k, v := range tags {
686
+ // key := k
687
+ // val := v
688
+ // request.Tags = append(request.Tags, &tke.Tag{
689
+ // Key: &key,
690
+ // Value: &val,
691
+ // })
692
+ // }
693
+ //}
694
+ //
695
+ //err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
696
+ // result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTkeClient().ModifyClusterNodePool(request)
697
+ // if e != nil {
698
+ // return tccommon.RetryError(e)
699
+ // } else {
700
+ // log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
701
+ // }
702
+ // return nil
703
+ //})
704
+ //if err != nil {
705
+ // log.Printf("[CRITAL]%s update kubernetes node pool failed, reason:%+v", logId, err)
706
+ // return err
707
+ //}
708
+
661
709
// todo wait for status ok
662
710
err = resource .Retry (5 * tccommon .ReadRetryTimeout , func () * resource.RetryError {
663
711
nodePool , _ , errRet := service .DescribeNodePool (ctx , clusterId , nodePoolId )
@@ -669,6 +717,7 @@ func resourceTencentCloudKubernetesNodePoolUpdateOnStart(ctx context.Context) er
669
717
}
670
718
return resource .RetryableError (fmt .Errorf ("node pool status is %s, retry..." , * nodePool .LifeState ))
671
719
})
720
+
672
721
if err != nil {
673
722
return err
674
723
}
0 commit comments