Merge pull request #15750 from ioito/hotfix/qx-vender-update-20230110

fix(region): vender update
This commit is contained in:
Zexi Li
2023-01-11 10:36:27 +08:00
committed by GitHub
7 changed files with 25 additions and 37 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ require (
k8s.io/client-go v0.19.3
k8s.io/cluster-bootstrap v0.19.3
moul.io/http2curl/v2 v2.3.0
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230106094242-0603d3751c54
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230110105742-0052589685ec
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656
yunion.io/x/jsonutils v1.0.1-0.20220819091305-3bab322ab4fd
yunion.io/x/log v1.0.0
+2 -2
View File
@@ -1158,8 +1158,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.20230106094242-0603d3751c54 h1:tzU1pOfDP4tLIoHLECa0uKPv+pPIoA4MZe3C5Os/3Gc=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230106094242-0603d3751c54/go.mod h1:yEMFtIKPyIdIfPzsw7oTcH41JXc8G5StUAQw3ZoGj5I=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230110105742-0052589685ec h1:p9OjNhquM20n3J39TY9XMx1LL2xJPKaPtHkrrP/1nAo=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230110105742-0052589685ec/go.mod h1:yEMFtIKPyIdIfPzsw7oTcH41JXc8G5StUAQw3ZoGj5I=
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 h1:0zlZD5uhZoIHgLVAWCz2aHaYk2ZrNsACCYD7R6EIBII=
yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
+2 -6
View File
@@ -906,12 +906,8 @@ func (self *SElasticip) AssociateNatGateway(ctx context.Context, userCred mcclie
if nat.Deleted {
return fmt.Errorf("nat gateway is deleted")
}
if len(self.AssociateType) > 0 && len(self.AssociateId) > 0 {
if self.AssociateType == api.EIP_ASSOCIATE_TYPE_NAT_GATEWAY && self.AssociateId == nat.Id {
return nil
} else {
return fmt.Errorf("Eip has been associated!!")
}
if len(self.AssociateId) > 0 && self.AssociateType == api.EIP_ASSOCIATE_TYPE_NAT_GATEWAY && self.AssociateId == nat.Id {
return nil
}
_, err := db.Update(self, func() error {
self.AssociateType = api.EIP_ASSOCIATE_TYPE_NAT_GATEWAY
+4 -2
View File
@@ -644,8 +644,8 @@ func (self *SNatGateway) GetEips() ([]SElasticip, error) {
}
func (self *SNatGateway) SyncNatGatewayEips(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extEips []cloudprovider.ICloudEIP) compare.SyncResult {
lockman.LockRawObject(ctx, "elasticip", self.Id)
defer lockman.ReleaseRawObject(ctx, "elasticip", self.Id)
lockman.LockRawObject(ctx, ElasticipManager.Keyword(), self.Id)
defer lockman.ReleaseRawObject(ctx, ElasticipManager.Keyword(), self.Id)
result := compare.SyncResult{}
@@ -673,6 +673,8 @@ func (self *SNatGateway) SyncNatGatewayEips(ctx context.Context, userCred mcclie
result.Delete()
}
result.UpdateCnt = len(commondb)
for i := 0; i < len(added); i += 1 {
region, _ := self.GetRegion()
neip, err := ElasticipManager.getEipByExtEip(ctx, userCred, added[i], provider, region, provider.GetOwnerId())
+1 -1
View File
@@ -1439,7 +1439,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.20230106094242-0603d3751c54
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20230110105742-0052589685ec
## explicit; go 1.18
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
+11 -25
View File
@@ -107,33 +107,19 @@ func (gateway *SNatGateway) GetExpiredAt() time.Time {
}
func (gateway *SNatGateway) GetIEips() ([]cloudprovider.ICloudEIP, error) {
IEips, err := gateway.region.GetIEips()
ports, err := gateway.region.GetPorts(gateway.ID)
if err != nil {
return nil, errors.Wrapf(err, `get all Eips of region %q error`, gateway.region.GetId())
return nil, errors.Wrapf(err, "GetPorts(%s)", gateway.ID)
}
dNatTables, err := gateway.GetINatDTable()
if err != nil {
return nil, errors.Wrapf(err, `get all DNatTable of gateway %q error`, gateway.GetId())
}
sNatTables, err := gateway.GetINatSTable()
if err != nil {
return nil, errors.Wrapf(err, `get all SNatTable of gateway %q error`, gateway.GetId())
}
// Get natIPSet of nat rules
natIPSet := make(map[string]struct{})
for _, snat := range sNatTables {
natIPSet[snat.GetIP()] = struct{}{}
}
for _, dnat := range dNatTables {
natIPSet[dnat.GetExternalIp()] = struct{}{}
}
// Add Eip whose GetIpAddr() in natIPSet to ret
ret := make([]cloudprovider.ICloudEIP, 0, 2)
for i := range IEips {
if _, ok := natIPSet[IEips[i].GetIpAddr()]; ok {
ret = append(ret, IEips[i])
ret := []cloudprovider.ICloudEIP{}
for i := range ports {
eips, err := gateway.region.GetEips(ports[i].ID, nil)
if err != nil {
return nil, err
}
for i := range eips {
eips[i].region = gateway.region
ret = append(ret, &eips[i])
}
}
return ret, nil
+4
View File
@@ -438,6 +438,10 @@ func (instance *SInstance) Refresh() error {
if err != nil {
return err
}
instance.Addresses = nil
instance.VolumesAttached = nil
instance.SecurityGroups = nil
instance.Tags = nil
return jsonutils.Update(instance, _instance)
}