fix(region): aliyun route table sync

This commit is contained in:
ioito
2021-12-10 16:34:27 +08:00
parent d214efdb65
commit 8b27985b01
3 changed files with 17 additions and 6 deletions
@@ -18,6 +18,7 @@ import (
"context"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
api "yunion.io/x/onecloud/pkg/apis/compute"
@@ -57,14 +58,15 @@ func (self *RouteTableSyncStatusTask) OnInit(ctx context.Context, obj db.IStanda
}
err = routeTable.SyncWithCloudRouteTable(ctx, self.GetUserCred(), vpc, iRouteTable, nil)
if err != nil {
self.taskFailed(ctx, routeTable, errors.Wrapf(err, "routeTable.GetICloudRouteTable()"))
self.taskFailed(ctx, routeTable, errors.Wrapf(err, "SyncWithCloudRouteTable"))
return
}
result := routeTable.SyncRouteTableRouteSets(ctx, self.GetUserCred(), iRouteTable, nil)
if result.IsError() {
self.taskFailed(ctx, routeTable, errors.Wrapf(result.AllError(), "routeTable.SyncRouteTableRouteSets()"))
self.taskFailed(ctx, routeTable, errors.Wrapf(result.AllError(), "SyncRouteTableRouteSets"))
return
}
log.Infof("sync route table for %s result: %s", routeTable.GetName(), result.Result())
result = routeTable.SyncRouteTableAssociations(ctx, self.GetUserCred(), iRouteTable, nil)
if result.IsError() {
+3 -3
View File
@@ -48,7 +48,7 @@ type SRouteEntry struct {
}
func (route *SRouteEntry) GetId() string {
return route.RouteEntryId
return fmt.Sprintf("%s-%s-%s", route.RouteTableId, route.DestinationCidrBlock, route.NextHopType)
}
func (route *SRouteEntry) GetName() string {
@@ -152,7 +152,7 @@ func (self *SRouteTable) GetDescription() string {
}
func (self *SRouteTable) GetId() string {
return self.GetGlobalId()
return self.RouteTableId
}
func (self *SRouteTable) GetGlobalId() string {
@@ -206,7 +206,7 @@ func (self *SRouteTable) Refresh() error {
}
func (self *SRouteTable) fetchRoutes() error {
routes := make([]*SRouteEntry, 0)
routes := []*SRouteEntry{}
for {
parts, total, err := self.RemoteGetRoutes(len(routes), 50)
if err != nil {
+10 -1
View File
@@ -232,7 +232,16 @@ func (self *SVpc) GetIRouteTables() ([]cloudprovider.ICloudRouteTable, error) {
}
func (self *SVpc) GetIRouteTableById(routeTableId string) (cloudprovider.ICloudRouteTable, error) {
return nil, cloudprovider.ErrNotSupported
tables, err := self.GetIRouteTables()
if err != nil {
return nil, errors.Wrapf(err, "GetIRouteTables")
}
for i := range tables {
if tables[i].GetGlobalId() == routeTableId {
return tables[i], nil
}
}
return nil, errors.Wrapf(cloudprovider.ErrNotFound, routeTableId)
}
func (self *SVpc) Delete() error {