From 5537fcf7be265fcc7d67edc2ec82f5f407ea373a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Thu, 3 Jul 2025 05:32:34 +0800 Subject: [PATCH] fix(region): vendor update for sync mongodb ip addr (#22816) --- go.mod | 2 +- go.sum | 4 +-- pkg/compute/models/elastic_search.go | 4 +-- pkg/compute/models/mongodb.go | 4 +-- vendor/modules.txt | 2 +- .../cloudmux/pkg/multicloud/aliyun/mongodb.go | 36 ++++++++++++++++++- 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 947e33461a..9a0734de99 100644 --- a/go.mod +++ b/go.mod @@ -95,7 +95,7 @@ require ( k8s.io/cri-api v0.22.17 k8s.io/klog/v2 v2.20.0 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702103535-3b73951ea9d1 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702132657-37b1f1b0b8bd yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 yunion.io/x/jsonutils v1.0.1-0.20250507052344-1abcf4f443b1 yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91 diff --git a/go.sum b/go.sum index dbe4de039c..3ec86c2c20 100644 --- a/go.sum +++ b/go.sum @@ -1406,8 +1406,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702103535-3b73951ea9d1 h1:OkXSEynpcz9DmsT7LHbmn+oK7N4B5fOQGxG7S4GQCTI= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702103535-3b73951ea9d1/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702132657-37b1f1b0b8bd h1:rSW+0utEdUqU76aD5PjvWPSRqr9bwdLprLb5wIsK8K8= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702132657-37b1f1b0b8bd/go.mod h1:FXxAEbdNfWXX9gjME3K2nJhkydHY5EKEUZb+RLEzVwQ= yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0 h1:msG4SiDSVU7CrXH06WuHlNEZXIooTcmNbfrIGHuIHBU= yunion.io/x/executor v0.0.0-20250518005516-5402e9e0bed0/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= diff --git a/pkg/compute/models/elastic_search.go b/pkg/compute/models/elastic_search.go index 825ecd50e8..ef166fb5d7 100644 --- a/pkg/compute/models/elastic_search.go +++ b/pkg/compute/models/elastic_search.go @@ -91,13 +91,13 @@ type SElasticSearch struct { // 存储类型 // example: local_ssd - StorageType string `nullable:"false" list:"user" create:"required"` + StorageType string `width:"16" charset:"utf8" nullable:"false" list:"user" create:"required"` // 存储大小 // example: 1024 DiskSizeGb int `nullable:"false" list:"user" create:"required"` // 实例类型 // example: ha - Category string `nullable:"false" list:"user" create:"optional"` + Category string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"optional"` VpcId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional" json:"vpc_id"` NetworkId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional" json:"network_id"` diff --git a/pkg/compute/models/mongodb.go b/pkg/compute/models/mongodb.go index 41b7657702..b16ea6c43b 100644 --- a/pkg/compute/models/mongodb.go +++ b/pkg/compute/models/mongodb.go @@ -94,7 +94,7 @@ type SMongoDB struct { Port int `nullable:"false" list:"user" create:"optional"` // 实例类型 // example: ha - Category string `nullable:"false" list:"user" create:"optional"` + Category string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 分片数量 // example: 3 @@ -105,7 +105,7 @@ type SMongoDB struct { Iops int `nullable:"true" list:"user" create:"optional"` // 实例IP地址 - IpAddr string `nullable:"false" list:"user"` + IpAddr string `width:"32" charset:"ascii" nullable:"true" list:"user"` // 引擎 // example: MySQL diff --git a/vendor/modules.txt b/vendor/modules.txt index d05a6cccad..42d0d0c638 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1849,7 +1849,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702103535-3b73951ea9d1 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20250702132657-37b1f1b0b8bd ## explicit; go 1.21 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/mongodb.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/mongodb.go index 19beb006a0..c8a26ae0e7 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/mongodb.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/mongodb.go @@ -149,7 +149,15 @@ func (self *SMongoDB) GetExpiredAt() time.Time { } func (self *SMongoDB) GetIpAddr() string { - return "" + nets, err := self.region.DescribeShardingNetworkAddress(self.DBInstanceId) + if err != nil { + return "" + } + ret := []string{} + for _, n := range nets { + ret = append(ret, n.IPAddress) + } + return strings.Join(ret, ",") } func (self *SMongoDB) GetEngine() string { @@ -508,6 +516,32 @@ func getMongoDBSkuDetails(remark string) struct { return ret } +type SMongoDBNetworkAddress struct { + IPAddress string + NetworkAddress string + NetworkType string + Port int + Role string + VpcId string + VswitchId string +} + +func (region *SRegion) DescribeShardingNetworkAddress(id string) ([]SMongoDBNetworkAddress, error) { + params := map[string]string{ + "DBInstanceId": id, + } + resp, err := region.mongodbRequest("DescribeShardingNetworkAddress", params) + if err != nil { + return nil, errors.Wrapf(err, "DescribeAvailableResource") + } + ret := []SMongoDBNetworkAddress{} + err = resp.Unmarshal(&ret, "NetworkAddresses", "NetworkAddress") + if err != nil { + return nil, err + } + return ret, nil +} + func (self *SRegion) GetMongoDBAvailableResource() (*SMongoDBAvaibaleResource, error) { params := map[string]string{} resp, err := self.mongodbRequest("DescribeAvailableResource", params)