Merge pull request #13013 from ioito/hotfix/qx-vpc-peer-connection-sync

fix(region): 对等连接同步状态恢复对端id
This commit is contained in:
Zexi Li
2021-12-24 18:09:22 +08:00
committed by GitHub
+13 -1
View File
@@ -355,11 +355,23 @@ func (self *SVpcPeeringConnection) syncRemove(ctx context.Context, userCred mccl
}
func (self *SVpcPeeringConnection) SyncWithCloudPeerConnection(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudVpcPeeringConnection, provider *SCloudprovider) error {
_, err := db.Update(self, func() error {
vpc, err := self.GetVpc()
if err != nil {
return errors.Wrapf(err, "GetVpc")
}
_, err = db.Update(self, func() error {
self.Status = ext.GetStatus()
self.ExternalId = ext.GetGlobalId()
self.ExtPeerVpcId = ext.GetPeerVpcId()
self.ExtPeerAccountId = ext.GetPeerAccountId()
peerVpc, _ := db.FetchByExternalIdAndManagerId(VpcManager, self.ExtPeerVpcId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
managerQ := CloudproviderManager.Query("id").Equals("provider", vpc.GetProviderName())
return q.In("manager_id", managerQ.SubQuery())
})
if peerVpc != nil {
self.PeerVpcId = peerVpc.GetId()
}
return nil
})
if err != nil {