Skip to content

Commit 35bc54d

Browse files
committed
Add features in blb,Fix bug in mcp
1 parent 45a1fc2 commit 35bc54d

File tree

7 files changed

+197
-8
lines changed

7 files changed

+197
-8
lines changed

Changelog

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
发行说明:记录每次SDK更新的说明,最新版本的SDK包含以前所有版本的更新内容。
22
---------------------------------------------------------------------
33

4+
【版本:v0.9.212】
5+
涉及产品:BLB
6+
BLB 应用型BLB-IP组开放协议支持健康检查协议切换
7+
涉及产品:MCP
8+
MCP Insert text修改为指针类型
9+
410
【版本:v0.9.211】
511
涉及产品:DDC
612
创建实例支持设置参数、备份列表及binlog备份列表新增返回值、新增多实例批量修改的参数的接口

bce/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
// Constants and default values for the package bce
2828
const (
29-
SDK_VERSION = "0.9.211"
29+
SDK_VERSION = "0.9.212"
3030
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
3131
DEFAULT_DOMAIN = "baidubce.com"
3232
DEFAULT_PROTOCOL = "http"

services/appblb/model.go

+2
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ type CreateAppIpGroupBackendPolicyArgs struct {
699699
IpGroupId string `json:"ipGroupId"`
700700
Type string `json:"type"`
701701
EnableHealthCheck *bool `json:"enableHealthCheck,omitempty"`
702+
HealthCheck string `json:"healthCheck,omitempty"`
702703
HealthCheckPort int `json:"healthCheckPort,omitempty"`
703704
HealthCheckHost string `json:"healthCheckHost,omitempty"`
704705
HealthCheckTimeoutInSecond int `json:"healthCheckTimeoutInSecond,omitempty"`
@@ -715,6 +716,7 @@ type UpdateAppIpGroupBackendPolicyArgs struct {
715716
IpGroupId string `json:"ipGroupId"`
716717
Id string `json:"id"`
717718
EnableHealthCheck *bool `json:"enableHealthCheck,omitempty"`
719+
HealthCheck string `json:"healthCheck,omitempty"`
718720
HealthCheckPort int `json:"healthCheckPort,omitempty"`
719721
HealthCheckHost string `json:"healthCheckHost,omitempty"`
720722
HealthCheckUrlPath string `json:"healthCheckUrlPath,omitempty"`

services/cce/v2/ccev2_test.go

+162-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
bccapi "github.com/baidubce/bce-sdk-go/services/bcc/api"
14+
"github.com/baidubce/bce-sdk-go/services/cce/v2/model"
1415
"github.com/baidubce/bce-sdk-go/services/cce/v2/types"
1516
"github.com/baidubce/bce-sdk-go/util/log"
1617
)
@@ -67,7 +68,8 @@ func setup() {
6768

6869
// ExpectEqual is the helper function for test each case
6970
func ExpectEqual(alert func(format string, args ...interface{}),
70-
expected interface{}, actual interface{}) bool {
71+
expected interface{}, actual interface{},
72+
) bool {
7173
expectedValue, actualValue := reflect.ValueOf(expected), reflect.ValueOf(actual)
7274
equal := false
7375
switch {
@@ -202,7 +204,7 @@ func TestClient_CreateCluster(t *testing.T) {
202204
s, _ := json.MarshalIndent(resp, "", "\t")
203205
fmt.Println("Response:" + string(s))
204206

205-
//等集群创建完成
207+
// 等集群创建完成
206208
time.Sleep(time.Duration(180) * time.Second)
207209
}
208210

@@ -427,7 +429,7 @@ func TestClient_UpdateInstanceGroupClusterAutoscalerSpec(t *testing.T) {
427429
func TestClient_GetKubeConfig(t *testing.T) {
428430
args := &GetKubeConfigArgs{
429431
ClusterID: CCE_CLUSTER_ID,
430-
KubeConfigType: KubeConfigTypeVPC,
432+
KubeConfigType: model.KubeConfigTypeVPC,
431433
}
432434

433435
resp, err := CCE_CLIENT.GetKubeConfig(args)
@@ -657,7 +659,6 @@ func TestClient_InstanceCRD(t *testing.T) {
657659

658660
func TestClient_UpdateClusterCRD(t *testing.T) {
659661
getClusterCRDArgs := &GetClusterCRDArgs{
660-
661662
ClusterID: "cce-bvyohjkg",
662663
}
663664

@@ -686,3 +687,160 @@ func TestClient_UpdateClusterCRD(t *testing.T) {
686687

687688
fmt.Printf("Resuest ID: %s", commonResp.RequestID)
688689
}
690+
691+
// TestClient_AttachInstancesToInstanceGroup 添加已有节点至节点组
692+
func TestClient_AttachInstancesToInstanceGroup(t *testing.T) {
693+
var (
694+
ak = ""
695+
sk = ""
696+
endpoint = ""
697+
clusterID = ""
698+
instanceGroupID = ""
699+
existInstanceID = ""
700+
AdminPassword = ""
701+
// rebuild 是否重装操作系统
702+
rebuild = true
703+
// useInstanceGroupConfig 是否使用节点组配置
704+
useInstanceGroupConfig = true
705+
// useLocalDiskForContainer 是否使用本地盘保存数据
706+
useLocalDiskForContainer = false
707+
imageID = ""
708+
)
709+
710+
cceClient, err := NewClient(ak, sk, endpoint)
711+
if err != nil {
712+
fmt.Printf("NewClient error: %s", err.Error())
713+
return
714+
}
715+
716+
attachInstanceToInstanceGroupArgs := func() *AttachInstancesToInstanceGroupArgs {
717+
args := AttachInstancesToInstanceGroupArgs{}
718+
args.ClusterID = clusterID
719+
args.InstanceGroupID = instanceGroupID
720+
args.Request = &AttachInstancesToInstanceGroupRequest{
721+
ExistedInstances: make([]*InstanceSet, 0),
722+
UseInstanceGroupConfig: useInstanceGroupConfig,
723+
}
724+
existInstance := &InstanceSet{
725+
InstanceSpec: types.InstanceSpec{
726+
Existed: true,
727+
ExistedOption: types.ExistedOption{
728+
// bcc 实例 id
729+
ExistedInstanceID: existInstanceID,
730+
Rebuild: &rebuild,
731+
},
732+
// 看具体的类型,bcc,bbc,ebc
733+
MachineType: types.MachineTypeBCC,
734+
ClusterRole: types.ClusterRoleNode,
735+
736+
// 二选一
737+
AdminPassword: AdminPassword,
738+
SSHKeyID: "",
739+
},
740+
}
741+
742+
// 如果需要重装操作系统,需要配置这里
743+
if rebuild {
744+
existInstance.InstanceSpec.InstanceOS = types.InstanceOS{
745+
ImageType: bccapi.ImageTypeSystem,
746+
}
747+
existInstance.InstanceSpec.ImageID = imageID
748+
}
749+
750+
if useLocalDiskForContainer {
751+
// 将容器数据存储在数据盘或本地盘中
752+
existInstance.InstanceSpec.InstanceResource = types.InstanceResource{
753+
CDSList: types.CDSConfigList{
754+
{
755+
DataDevice: "/dev/xxx",
756+
Path: "/home/cce",
757+
},
758+
},
759+
}
760+
}
761+
if !useInstanceGroupConfig {
762+
existInstance.InstanceSpec.VPCConfig = types.VPCConfig{
763+
SecurityGroups: []types.SecurityGroupV2{
764+
{
765+
ID: "",
766+
Name: "",
767+
Type: types.SecurityGroupTypeNormal,
768+
},
769+
},
770+
}
771+
existInstance.InstanceSpec.DeployCustomConfig = types.DeployCustomConfig{
772+
KubeletRootDir: "",
773+
PreUserScript: "",
774+
PostUserScript: "",
775+
}
776+
// 标签配置
777+
existInstance.InstanceSpec.Tags = types.TagList{
778+
{
779+
TagKey: "",
780+
TagValue: "",
781+
},
782+
}
783+
}
784+
args.Request.ExistedInstances = append(args.Request.ExistedInstances, existInstance)
785+
return &args
786+
}()
787+
commonResp, err := cceClient.AttachInstancesToInstanceGroup(attachInstanceToInstanceGroupArgs)
788+
if err != nil {
789+
fmt.Printf("attach instance to instance group failed, errir: %v", err)
790+
return
791+
}
792+
fmt.Printf("Request ID: %s", commonResp.RequestID)
793+
}
794+
795+
func TestClient_CreateScaleDownInstanceGroupTask(t *testing.T) {
796+
type fields struct {
797+
ak, sk, endpoint string
798+
}
799+
type args struct {
800+
args *CreateScaleDownInstanceGroupTaskArgs
801+
}
802+
tests := []struct {
803+
name string
804+
fields fields
805+
args args
806+
}{
807+
{
808+
name: "移出已有节点",
809+
fields: fields{
810+
ak: "",
811+
sk: "",
812+
endpoint: "",
813+
},
814+
args: args{
815+
args: &CreateScaleDownInstanceGroupTaskArgs{
816+
InstancesToBeRemoved: []string{""},
817+
ClusterID: "",
818+
InstanceGroupID: "",
819+
CleanPolicy: CleanPolicyDelete,
820+
DeleteOption: &types.DeleteOption{
821+
DeleteCDSSnapshot: false,
822+
DeleteResource: false,
823+
DrainNode: false,
824+
MoveOut: true,
825+
},
826+
},
827+
},
828+
},
829+
}
830+
for _, tt := range tests {
831+
t.Run(tt.name, func(t *testing.T) {
832+
c, err := NewClient(tt.fields.ak, tt.fields.sk, tt.fields.endpoint)
833+
if err != nil {
834+
t.Errorf("failed init client, error = %v", err)
835+
return
836+
}
837+
if resp, err := c.CreateScaleDownInstanceGroupTask(tt.args.args); err != nil {
838+
t.Errorf("CreateScaleDownInstanceGroupTask() error = %v", err)
839+
840+
} else {
841+
t.Logf("request id is: %s", resp.RequestID)
842+
}
843+
844+
})
845+
}
846+
}

services/cce/v2/types/instance.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
// InstanceSpec 已有节点需要用户提供:ClusterRole 、短ID,密码,镜像ID,镜像类型, docker storage(可选); BBC要额外加preservedData、raidId、sysRootSize
1818
type InstanceSpec struct {
19-
2019
// 用于 CCE 唯一标识 Instance
2120
CCEInstanceID string `json:"cceInstanceID,omitempty"`
2221
InstanceName string `json:"instanceName"`
@@ -111,6 +110,8 @@ type VPCConfig struct {
111110
SecurityGroup SecurityGroup `json:"securityGroup,omitempty"`
112111

113112
SecurityGroupType string `json:"securityGroupType"`
113+
114+
SecurityGroups []SecurityGroupV2 `json:"securityGroups"`
114115
}
115116

116117
// SecurityGroup 定义 Instance 安全组配置
@@ -123,6 +124,23 @@ type SecurityGroup struct {
123124
CustomSecurityGroupIDs []string `json:"customSecurityGroups,omitempty"`
124125
}
125126

127+
type SecurityGroupV2 struct {
128+
Name string `json:"name"`
129+
Type SecurityGroupType `json:"type"`
130+
ID string `json:"id"`
131+
}
132+
133+
type SecurityGroupType string
134+
135+
const (
136+
// 普通安全组
137+
SecurityGroupTypeNormal SecurityGroupType = "normal"
138+
// 企业安全组
139+
SecurityGroupTypeEnterprise SecurityGroupType = "enterprise"
140+
SecurityGroupTypeNormalIDPrefix string = "g-"
141+
SecurityGroupTypeEnterpriseIDPrefix string = "esg-"
142+
)
143+
126144
// InstanceResource 定义 Instance CPU/MEM/Disk 配置
127145
type InstanceResource struct {
128146
MachineSpec string `json:"machineSpec,omitempty"` // 机器规格,例:bcc.g5.c2m8
@@ -210,6 +228,7 @@ type DeleteOption struct {
210228
MoveOut bool `json:"moveOut,omitempty"`
211229
DeleteResource bool `json:"deleteResource,omitempty"`
212230
DeleteCDSSnapshot bool `json:"deleteCDSSnapshot,omitempty"`
231+
DrainNode bool `json:"drainNode,omitempty"`
213232
}
214233

215234
// BBCOption BBC 相关配置
@@ -272,6 +291,7 @@ type DeployCustomConfig struct {
272291
// KubeletBindAddressType, kubelet bind address
273292
KubeletBindAddressType KubeletBindAddressType `json:"kubeletBindAddressType,omitempty"`
274293

294+
// PostUserScriptFailedAutoCordon 部署后执行脚本失败自动封锁节点
275295
PostUserScriptFailedAutoCordon bool `json:"postUserScriptFailedAutoCordon,omitempty"`
276296
}
277297

@@ -320,6 +340,8 @@ type CDSConfig struct {
320340
StorageType bccapi.StorageType `json:"storageType,omitempty"`
321341
CDSSize int `json:"cdsSize,omitempty"`
322342
SnapshotID string `json:"snapshotID,omitempty"`
343+
DataDevice string `json:"dataDevice,omitempty"`
344+
NeedFormat bool `json:"needFormat,omitempty"`
323345
}
324346

325347
// MountConfig - 磁盘挂载信息

services/cce/v2/url.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"fmt"
1515

1616
"github.com/baidubce/bce-sdk-go/bce"
17+
"github.com/baidubce/bce-sdk-go/services/cce/v2/model"
1718
"github.com/baidubce/bce-sdk-go/services/cce/v2/types"
1819
)
1920

@@ -216,7 +217,7 @@ func getAutoscalerURI(clusterID string) string {
216217
return URI_PREFIX + REQUEST_AUTOSCALER + "/" + clusterID
217218
}
218219

219-
func getKubeconfigURI(clusterID string, kubeConfigType KubeConfigType) string {
220+
func getKubeconfigURI(clusterID string, kubeConfigType model.KubeConfigType) string {
220221
return URI_PREFIX + fmt.Sprintf(REQUEST_KUBECONFIG, clusterID, kubeConfigType)
221222
}
222223

services/media/api/model.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type Insert struct {
105105
Bucket string `json:"bucket,omitempty"`
106106
Key string `json:"key,omitempty"`
107107
Type string `json:"type,omitempty"`
108-
Text string `json:"text"`
108+
Text *string `json:"text"`
109109
Font *Font `json:"font,omitempty"`
110110
Timeline *Timeline `json:"timeline"`
111111
Layout *Layout `json:"layout,omitempty"`

0 commit comments

Comments
 (0)