From 4833e9ed1b3c940cc40c2745d15e4a055cc1a942 Mon Sep 17 00:00:00 2001 From: dove0012 Date: Fri, 3 Jul 2026 11:33:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=8D=8E=E4=B8=BA?= =?UTF-8?q?=E4=BA=91sdk=E5=BA=93=E5=88=B0=E6=9C=80=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E8=AE=BE=E7=BD=AE=E5=88=9B=E5=BB=BA=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=B1=A0=E6=B1=A1=E7=82=B9=EF=BC=8C=E6=A0=87=E7=AD=BE=EF=BC=8C?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=A0=87=E7=AD=BE=E7=9A=84=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=B8=BAignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bcs-services/bcs-cluster-manager/go.mod | 9 +++- .../internal/cloudprovider/huawei/api/cce.go | 4 +- .../cloudprovider/huawei/api/types.go | 41 +++++++++++-------- .../cloudprovider/huawei/api/utils.go | 18 ++++---- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/bcs-services/bcs-cluster-manager/go.mod b/bcs-services/bcs-cluster-manager/go.mod index ab343fa31d..9e7e1b7bc3 100644 --- a/bcs-services/bcs-cluster-manager/go.mod +++ b/bcs-services/bcs-cluster-manager/go.mod @@ -38,7 +38,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.154 + github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.199 github.com/kirito41dd/xslice v0.0.1 github.com/leodido/go-urn v1.4.0 // indirect github.com/parnurzeal/gorequest v0.2.16 @@ -117,6 +117,7 @@ require ( github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.5.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect + github.com/fatih/color v1.10.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect @@ -138,6 +139,7 @@ require ( github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/pool v0.2.1 // indirect github.com/gobwas/ws v1.0.4 // indirect + github.com/goccy/go-yaml v1.9.8 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect @@ -166,7 +168,7 @@ require ( github.com/jinzhu/now v1.1.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect + github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect github.com/juju/ratelimit v1.0.1 // indirect github.com/kelseyhightower/envconfig v1.4.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect @@ -175,6 +177,8 @@ require ( github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/miekg/dns v1.1.50 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/hashstructure v1.1.0 // indirect @@ -240,6 +244,7 @@ require ( golang.org/x/term v0.27.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/cce.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/cce.go index 657cb5d87d..a69c51721d 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/cce.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/cce.go @@ -198,8 +198,8 @@ func (cli *CceClient) CreateKubernetesClusterCert(clsId string, duration int32) request := &model.CreateKubernetesClusterCertRequest{ ClusterId: clsId, } - request.Body = &model.CertDuration{ - Duration: duration, + request.Body = &model.ClusterCertDuration{ + Duration: &duration, } response, err := cli.cce.CreateKubernetesClusterCert(request) diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go index 5d07c9966c..1cc8c631b0 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go @@ -293,8 +293,8 @@ type PublicIp struct { Enable bool } -func GetChargeConfig(charge ChargePrepaid) (billingMode int32, periodType string, periodNum int32, - isAutoRenew string, isAutoPay string) { +func GetChargeConfig(charge ChargePrepaid) (billingMode model.NodeTemplateBillingMode, periodType string, + periodNum int32, isAutoRenew string, isAutoPay string) { periodType = "month" periodNum = 1 isAutoRenew = "false" @@ -302,7 +302,7 @@ func GetChargeConfig(charge ChargePrepaid) (billingMode int32, periodType string periodNum = int32(charge.Period) if charge.ChargeType == icommon.PREPAID { - billingMode = 1 + billingMode = model.GetNodeTemplateBillingModeEnum().E_1 if charge.Period >= 12 { periodType = "year" periodNum = int32(charge.Period / 12) @@ -314,11 +314,11 @@ func GetChargeConfig(charge ChargePrepaid) (billingMode int32, periodType string return } -func GetPublicIp(publicIp PublicIp) *model.NodePublicIp { +func GetPublicIp(publicIp PublicIp) *model.NodeEipSpec { if publicIp.Enable { shareType := eipModel.GetCreatePublicipBandwidthOptionShareTypeEnum().PER.Value() - return &model.NodePublicIp{ - Iptype: common.StringPtr("5_bgp"), + return &model.NodeEipSpec{ + Iptype: "5_bgp", Bandwidth: &model.NodeBandwidth{ Chargemode: func() *string { if publicIp.ChangeType == ChargemodeBandwidth { @@ -355,8 +355,9 @@ func GetRuntime(containerRuntime string) *model.Runtime { func (req CreateNodePoolRequest) trans2NodePoolTemplate() *model.CreateNodePoolRequest { var ( - NodePoolSpecType = model.GetNodePoolSpecTypeEnum().VM - taints = Taint2ModelTaint(req.Spec.Template.Taints) + NodePoolSpecType = model.GetNodePoolSpecTypeEnum().VM + taints = Taint2ModelTaint(req.Spec.Template.Taints) + policyOnExistingNodes = "ignore" ) dataVolumes, storageSelectors, storageGroups := GetDataVolumeAndStorgeConfig(req.Spec.Template.DataVolumes) @@ -373,22 +374,22 @@ func (req CreateNodePoolRequest) trans2NodePoolTemplate() *model.CreateNodePoolR }, Spec: &model.NodePoolSpec{ Type: &NodePoolSpecType, - NodeTemplate: &model.NodeSpec{ - Flavor: req.Spec.Template.Flavor, - Az: req.Spec.Template.Az, + NodeTemplate: &model.NodeTemplate{ + Flavor: &req.Spec.Template.Flavor, + Az: &req.Spec.Template.Az, Os: &req.Spec.Template.Os, Login: Login2ModelLogin(&req.Spec.Template.Login), RootVolume: &model.Volume{ Size: req.Spec.Template.RootVolume.Size, Volumetype: req.Spec.Template.RootVolume.VolumeType, }, - DataVolumes: dataVolumes, + DataVolumes: &dataVolumes, Storage: &model.Storage{ StorageSelectors: storageSelectors, StorageGroups: storageGroups, }, BillingMode: &billingMode, - Taints: &taints, + Taints: taints, K8sTags: req.Spec.Template.Labels, Runtime: GetRuntime(req.Spec.Template.ContainerRuntime), InitializedConditions: &[]string{ @@ -419,6 +420,9 @@ func (req CreateNodePoolRequest) trans2NodePoolTemplate() *model.CreateNodePoolR } return &securityIds }(), + TaintPolicyOnExistingNodes: &policyOnExistingNodes, + LabelPolicyOnExistingNodes: &policyOnExistingNodes, + UserTagsPolicyOnExistingNodes: &policyOnExistingNodes, }, }, } @@ -477,7 +481,7 @@ func (un UpdateNodePoolRequest) trans2ModelUpdateNodePoolRequest(clsId string, n } nodePoolMeta := &model.NodePoolMetadataUpdate{ - Name: un.Name, + Name: &un.Name, } nodeSpec := &model.NodeSpecUpdate{ @@ -533,7 +537,7 @@ type AddNodesRequest struct { } // Taint2ModelTaint trans taint -func Taint2ModelTaint(taints []v1.Taint) []model.Taint { +func Taint2ModelTaint(taints []v1.Taint) *[]model.Taint { mTaints := make([]model.Taint, 0) for i := range taints { @@ -544,7 +548,7 @@ func Taint2ModelTaint(taints []v1.Taint) []model.Taint { }) } - return mTaints + return &mTaints } // Login2ModelLogin trans login @@ -601,7 +605,7 @@ func (ar AddNodesRequest) Trans2AddNodesRequest(clsId string, opt *cloudprovider K8sOptions: func() *model.ReinstallK8sOptionsConfig { return &model.ReinstallK8sOptionsConfig{ Labels: ar.Labels, - Taints: &taints, + Taints: taints, MaxPods: &ar.MaxPods, } }(), @@ -957,6 +961,7 @@ func (c *CreateClusterRequest) Trans2CreateClusterRequest() *model.CreateCluster confOverName := "kube-apiserver" confName := "support-overload" var confValue interface{} = true + billingModeValue := billingMode.Value() req := &model.CreateClusterRequest{ Body: &model.Cluster{ @@ -982,7 +987,7 @@ func (c *CreateClusterRequest) Trans2CreateClusterRequest() *model.CreateCluster SecurityGroup: &c.Spec.SecurityGroupID, }, ServiceNetwork: &model.ServiceNetwork{IPv4CIDR: &c.Spec.ServiceCidr}, - BillingMode: &billingMode, + BillingMode: &billingModeValue, ClusterTags: &clusterTags, KubeProxyMode: func() *model.ClusterSpecKubeProxyMode { proxyMode := model.GetClusterSpecKubeProxyModeEnum().IPTABLES diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/utils.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/utils.go index c37de2e010..1558910a5e 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/utils.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/utils.go @@ -51,19 +51,21 @@ func GenerateModifyClusterNodePoolInput(group *proto.NodeGroup, clusterID string oldNodePool *model.NodePool) *model.UpdateNodePoolRequest { // cce nodePool名称以小写字母开头,由小写字母、数字、中划线(-)组成,长度范围1-50位,且不能以中划线(-)结尾 name := strings.ToLower(group.NodeGroupID) + taints := make([]model.Taint, 0) + userTags := make([]model.UserTag, 0) req := &model.UpdateNodePoolRequest{ NodepoolId: group.CloudNodeGroupID, ClusterId: clusterID, Body: &model.NodePoolUpdate{ Metadata: &model.NodePoolMetadataUpdate{ - Name: name, + Name: &name, }, Spec: &model.NodePoolSpecUpdate{ NodeTemplate: &model.NodeSpecUpdate{ - Taints: make([]model.Taint, 0), + Taints: &taints, K8sTags: map[string]string{}, - UserTags: make([]model.UserTag, 0), + UserTags: &userTags, }, //更新节点池不能更新节点数量,只能通过UpdateDesiredNodes方法更新,会影响互斥性 InitialNodeCount: *oldNodePool.Spec.InitialNodeCount, @@ -81,7 +83,7 @@ func GenerateModifyClusterNodePoolInput(group *proto.NodeGroup, clusterID string effect = model.GetTaintEffectEnum().NO_EXECUTE } value := v.Value - req.Body.Spec.NodeTemplate.Taints = append(req.Body.Spec.NodeTemplate.Taints, model.Taint{ + *req.Body.Spec.NodeTemplate.Taints = append(*req.Body.Spec.NodeTemplate.Taints, model.Taint{ Key: v.Key, Value: &value, Effect: effect, @@ -91,16 +93,16 @@ func GenerateModifyClusterNodePoolInput(group *proto.NodeGroup, clusterID string req.Body.Spec.NodeTemplate.K8sTags = group.NodeTemplate.Labels - if len(req.Body.Spec.NodeTemplate.Taints) == 0 && oldNodePool.Spec.NodeTemplate.Taints != nil { - req.Body.Spec.NodeTemplate.Taints = *oldNodePool.Spec.NodeTemplate.Taints + if len(*req.Body.Spec.NodeTemplate.Taints) == 0 && oldNodePool.Spec.NodeTemplate.Taints != nil { + req.Body.Spec.NodeTemplate.Taints = oldNodePool.Spec.NodeTemplate.Taints } if len(req.Body.Spec.NodeTemplate.K8sTags) == 0 && oldNodePool.Spec.NodeTemplate.K8sTags != nil { req.Body.Spec.NodeTemplate.K8sTags = oldNodePool.Spec.NodeTemplate.K8sTags } - if len(req.Body.Spec.NodeTemplate.UserTags) == 0 && oldNodePool.Spec.NodeTemplate.UserTags != nil { - req.Body.Spec.NodeTemplate.UserTags = *oldNodePool.Spec.NodeTemplate.UserTags + if len(*req.Body.Spec.NodeTemplate.UserTags) == 0 && oldNodePool.Spec.NodeTemplate.UserTags != nil { + req.Body.Spec.NodeTemplate.UserTags = oldNodePool.Spec.NodeTemplate.UserTags } return req From 86a182c90ee466dbb984239711d166338d61e72d Mon Sep 17 00:00:00 2001 From: dove0012 Date: Fri, 3 Jul 2026 16:48:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=B2=A1=E5=88=9D=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/cloudprovider/huawei/api/types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go index 1cc8c631b0..9b1c1d7379 100644 --- a/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go +++ b/bcs-services/bcs-cluster-manager/internal/cloudprovider/huawei/api/types.go @@ -299,6 +299,7 @@ func GetChargeConfig(charge ChargePrepaid) (billingMode model.NodeTemplateBillin periodNum = 1 isAutoRenew = "false" isAutoPay = "true" + billingMode = model.GetNodeTemplateBillingModeEnum().E_0 periodNum = int32(charge.Period) if charge.ChargeType == icommon.PREPAID {