From 4455a996456875dab78a18bc0916d44ba5dc52fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Mon, 15 Dec 2025 13:47:31 +0800 Subject: [PATCH] fix(region): add provider info for sync log (#23933) --- pkg/compute/models/cloudsync.go | 426 ++++++++++---------- pkg/compute/models/cloudsyncelasticcache.go | 6 +- pkg/compute/models/cloudsyncelb.go | 30 +- 3 files changed, 242 insertions(+), 220 deletions(-) diff --git a/pkg/compute/models/cloudsync.go b/pkg/compute/models/cloudsync.go index a05f6b2e47..6b52e2b79e 100644 --- a/pkg/compute/models/cloudsync.go +++ b/pkg/compute/models/cloudsync.go @@ -104,8 +104,11 @@ func syncRegionQuotas(ctx context.Context, userCred mcclient.TokenCredential, sy return remoteRegion.GetICloudQuotas() }() if err != nil { - msg := fmt.Sprintf("GetICloudQuotas for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return nil + } + msg := fmt.Sprintf("GetICloudQuotas for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } result := func() compare.SyncResult { @@ -114,7 +117,7 @@ func syncRegionQuotas(ctx context.Context, userCred mcclient.TokenCredential, sy }() syncResults.Add(CloudproviderQuotaManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncQuotas for region %s result: %s", localRegion.Name, msg) + notes := fmt.Sprintf("SyncQuotas for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) provider.SyncError(result, notes, userCred) log.Infof(notes) if result.IsError() { @@ -129,8 +132,8 @@ func syncRegionZones(ctx context.Context, userCred mcclient.TokenCredential, syn return remoteRegion.GetIZones() }() if err != nil { - msg := fmt.Sprintf("GetZones for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetZones for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return nil, nil, err } localZones, remoteZones, result := func() ([]SZone, []cloudprovider.ICloudZone, compare.SyncResult) { @@ -139,8 +142,8 @@ func syncRegionZones(ctx context.Context, userCred mcclient.TokenCredential, syn }() syncResults.Add(ZoneManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncZones for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncZones for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) db.OpsLog.LogEvent(provider, db.ACT_SYNC_HOST_COMPLETE, msg, userCred) return localZones, remoteZones, nil @@ -209,8 +212,11 @@ func syncRegionEips( return remoteRegion.GetIEips() }() if err != nil { - msg := fmt.Sprintf("GetIEips for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetIEips for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -222,8 +228,8 @@ func syncRegionEips( syncResults.Add(ElasticipManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncEips for region %s result: %s", localRegion.Name, msg) - log.Infof(msg) + notes := fmt.Sprintf("SyncEips for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", msg) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -236,8 +242,11 @@ func syncRegionBuckets(ctx context.Context, userCred mcclient.TokenCredential, s return remoteRegion.GetIBuckets() }() if err != nil { - msg := fmt.Sprintf("GetIBuckets for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetIBuckets for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -249,8 +258,8 @@ func syncRegionBuckets(ctx context.Context, userCred mcclient.TokenCredential, s syncResults.Add(BucketManager, result) msg := result.Result() - notes := fmt.Sprintf("GetIBuckets for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("GetIBuckets for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -272,8 +281,11 @@ func syncRegionVPCs( return remoteRegion.GetIVpcs() }() if err != nil { - msg := fmt.Sprintf("GetVpcs for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetVpcs for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -285,8 +297,8 @@ func syncRegionVPCs( syncResults.Add(VpcManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncVPCs for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncVPCs for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -325,7 +337,7 @@ func syncRegionAccessGroups(ctx context.Context, userCred mcclient.TokenCredenti if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { return } - log.Errorf("GetICloudFileSystems for region %s error: %v", localRegion.Name, err) + log.Errorf("GetICloudFileSystems for region %s provider %s error: %v", localRegion.Name, provider.Name, err) return } @@ -335,8 +347,8 @@ func syncRegionAccessGroups(ctx context.Context, userCred mcclient.TokenCredenti }() syncResults.Add(AccessGroupManager, result) msg := result.Result() - notes := fmt.Sprintf("Sync Access Group for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("Sync Access Group for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) } @@ -357,7 +369,7 @@ func syncRegionFileSystems( if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { return } - log.Errorf("GetICloudFileSystems for region %s error: %v", localRegion.Name, err) + log.Errorf("GetICloudFileSystems for region %s provider %s error: %v", localRegion.Name, provider.Name, err) return } @@ -368,8 +380,8 @@ func syncRegionFileSystems( syncResults.Add(FileSystemManager, result) msg := result.Result() - notes := fmt.Sprintf("Sync FileSystem for region %s result: %s", localRegion.Name, msg) - log.Infof(msg) + notes := fmt.Sprintf("Sync FileSystem for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) for j := 0; j < len(localFSs); j += 1 { @@ -424,7 +436,7 @@ func syncVpcPeerConnections( if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { return } - log.Errorf("GetICloudVpcPeeringConnections for vpc %s failed %v", localVpc.Name, err) + log.Errorf("GetICloudVpcPeeringConnections for vpc %s provider %s failed %v", localVpc.Name, provider.Name, err) return } @@ -442,7 +454,7 @@ func syncVpcPeerConnections( if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { return } - log.Errorf("GetICloudVpcPeeringConnections for vpc %s failed %v", localVpc.Name, err) + log.Errorf("GetICloudVpcPeeringConnections for vpc %s provider %s failed %v", localVpc.Name, provider.Name, err) return } backSyncResult := func() compare.SyncResult { @@ -451,8 +463,8 @@ func syncVpcPeerConnections( }() syncResults.Add(VpcPeeringConnectionManager, backSyncResult) - notes := fmt.Sprintf("SyncVpcPeeringConnections for vpc %s result: %s", localVpc.Name, result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("SyncVpcPeeringConnections for vpc %s provider %s result: %s", localVpc.Name, provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -473,8 +485,8 @@ func syncRegionSecGroup( return remoteRegion.GetISecurityGroups() }() if err != nil { - msg := fmt.Sprintf("GetISecurityGroups for region %s failed %s", localRegion.Name, err) - log.Errorf(msg) + msg := fmt.Sprintf("GetISecurityGroups for region %s provider %s failed %s", localRegion.Name, provider.Name, err) + log.Errorf("%s", msg) return } groups := []cloudprovider.ICloudSecurityGroup{} @@ -493,8 +505,8 @@ func syncRegionSecGroup( syncResults.Add(SecurityGroupManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncSecurityGroup for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncSecurityGroup for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -516,8 +528,8 @@ func syncVpcSecGroup( return remoteVpc.GetISecurityGroups() }() if err != nil { - msg := fmt.Sprintf("GetISecurityGroups for vpc %s failed %s", remoteVpc.GetId(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetISecurityGroups for vpc %s provider %s failed %s", remoteVpc.GetId(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -537,8 +549,8 @@ func syncVpcSecGroup( syncResults.Add(SecurityGroupManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncSecurityGroup for VPC %s result: %s", localVpc.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncSecurityGroup for VPC %s provider %s result: %s", localVpc.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -551,8 +563,8 @@ func syncVpcRouteTables(ctx context.Context, userCred mcclient.TokenCredential, return remoteVpc.GetIRouteTables() }() if err != nil { - msg := fmt.Sprintf("GetIRouteTables for vpc %s failed %s", remoteVpc.GetId(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIRouteTables for vpc %s provider %s failed %s", remoteVpc.GetId(), provider.Name, err) + log.Errorf("%s", msg) return } localRouteTables, remoteRouteTables, result := func() ([]SRouteTable, []cloudprovider.ICloudRouteTable, compare.SyncResult) { @@ -563,8 +575,8 @@ func syncVpcRouteTables(ctx context.Context, userCred mcclient.TokenCredential, syncResults.Add(RouteTableManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncRouteTables for VPC %s result: %s", localVpc.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncRouteTables for VPC %s provider %s result: %s", localVpc.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -589,8 +601,8 @@ func syncIPv6Gateways(ctx context.Context, userCred mcclient.TokenCredential, sy return remoteVpc.GetICloudIPv6Gateways() }() if err != nil { - msg := fmt.Sprintf("GetICloudIPv6Gateways for vpc %s failed %s", remoteVpc.GetId(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudIPv6Gateways for vpc %s provider %s failed %s", remoteVpc.GetId(), provider.Name, err) + log.Errorf("%s", msg) return } result := func() compare.SyncResult { @@ -601,8 +613,8 @@ func syncIPv6Gateways(ctx context.Context, userCred mcclient.TokenCredential, sy syncResults.Add(IPv6GatewayManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncIPv6Gateways for VPC %s result: %s", localVpc.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncIPv6Gateways for VPC %s provider %s result: %s", localVpc.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -618,8 +630,8 @@ func syncVpcNatgateways(ctx context.Context, userCred mcclient.TokenCredential, if errors.Cause(err) == cloudprovider.ErrNotImplemented { return } - msg := fmt.Sprintf("GetINatGateways for vpc %s failed %s", remoteVpc.GetId(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetINatGateways for vpc %s provider %s failed %s", remoteVpc.GetId(), provider.Name, err) + log.Errorf("%s", msg) return } localNatGateways, remoteNatGateways, result := func() ([]SNatGateway, []cloudprovider.ICloudNatGateway, compare.SyncResult) { @@ -630,8 +642,8 @@ func syncVpcNatgateways(ctx context.Context, userCred mcclient.TokenCredential, syncResults.Add(NatGatewayManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncNatGateways for VPC %s result: %s", localVpc.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNatGateways for VPC %s provider %s result: %s", localVpc.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -658,14 +670,14 @@ func syncVpcNatgateways(ctx context.Context, userCred mcclient.TokenCredential, func syncNatGatewayEips(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, localNatGateway *SNatGateway, remoteNatGateway cloudprovider.ICloudNatGateway) { eips, err := remoteNatGateway.GetIEips() if err != nil { - msg := fmt.Sprintf("GetIEIPs for NatGateway %s failed %s", remoteNatGateway.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIEIPs for NatGateway %s provider %s failed %s", remoteNatGateway.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := localNatGateway.SyncNatGatewayEips(ctx, userCred, provider, eips) msg := result.Result() - notes := fmt.Sprintf("SyncNatGatewayEips for NatGateway %s result: %s", localNatGateway.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNatGatewayEips for NatGateway %s provider %s result: %s", localNatGateway.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -683,14 +695,14 @@ func syncNatDTable( ) { dtable, err := remoteNatGateway.GetINatDTable() if err != nil { - msg := fmt.Sprintf("GetINatDTable for NatGateway %s failed %s", remoteNatGateway.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetINatDTable for NatGateway %s provider %s failed %s", remoteNatGateway.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := NatDEntryManager.SyncNatDTable(ctx, userCred, provider, localNatGateway, dtable, xor) msg := result.Result() - notes := fmt.Sprintf("SyncNatDTable for NatGateway %s result: %s", localNatGateway.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNatDTable for NatGateway %s provider %s result: %s", localNatGateway.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -708,14 +720,14 @@ func syncNatSTable( ) { stable, err := remoteNatGateway.GetINatSTable() if err != nil { - msg := fmt.Sprintf("GetINatSTable for NatGateway %s failed %s", remoteNatGateway.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetINatSTable for NatGateway %s provider %s failed %s", remoteNatGateway.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := NatSEntryManager.SyncNatSTable(ctx, userCred, provider, localNatGateway, stable, xor) msg := result.Result() - notes := fmt.Sprintf("SyncNatSTable for NatGateway %s result: %s", localNatGateway.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNatSTable for NatGateway %s provider %s result: %s", localNatGateway.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -733,8 +745,8 @@ func syncVpcWires(ctx context.Context, userCred mcclient.TokenCredential, syncRe return remoteVpc.GetIWires() }() if err != nil { - msg := fmt.Sprintf("GetIWires for vpc %s failed %s", remoteVpc.GetId(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIWires for vpc %s provider %s failed %s", remoteVpc.GetId(), provider.Name, err) + log.Errorf("%s", msg) return } localWires, remoteWires, result := func() ([]SWire, []cloudprovider.ICloudWire, compare.SyncResult) { @@ -751,8 +763,8 @@ func syncVpcWires(ctx context.Context, userCred mcclient.TokenCredential, syncRe } msg := result.Result() - notes := fmt.Sprintf("SyncWires for VPC %s result: %s", localVpc.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncWires for VPC %s provider %s result: %s", localVpc.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -786,8 +798,8 @@ func syncWireNetworks(ctx context.Context, userCred mcclient.TokenCredential, sy return remoteWire.GetINetworks() }() if err != nil { - msg := fmt.Sprintf("GetINetworks for wire %s failed %s", remoteWire.GetId(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetINetworks for wire %s provider %s failed %s", remoteWire.GetId(), provider.Name, err) + log.Errorf("%s", msg) return } _, _, result := func() ([]SNetwork, []cloudprovider.ICloudNetwork, compare.SyncResult) { @@ -804,8 +816,8 @@ func syncWireNetworks(ctx context.Context, userCred mcclient.TokenCredential, sy } msg := result.Result() - notes := fmt.Sprintf("SyncNetworks for wire %s result: %s", localWire.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNetworks for wire %s provider %s result: %s", localWire.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -828,8 +840,8 @@ func syncZoneStorages( return remoteZone.GetIStorages() }() if err != nil { - msg := fmt.Sprintf("GetIStorages for zone %s failed %s", remoteZone.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIStorages for zone %s provider %s failed %s", remoteZone.GetName(), provider.Name, err) + log.Errorf("%s", msg) return nil } localStorages, remoteStorages, result := func() ([]SStorage, []cloudprovider.ICloudStorage, compare.SyncResult) { @@ -840,8 +852,8 @@ func syncZoneStorages( syncResults.Add(StorageManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncStorages for zone %s result: %s", localZone.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncStorages for zone %s provider %s result: %s", localZone.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return nil @@ -860,7 +872,7 @@ func syncZoneStorages( if !isInCache(storageCachePairs, localStorages[i].StoragecacheId) && !isInCache(newCacheIds, localStorages[i].StoragecacheId) { cachePair, err := syncStorageCaches(ctx, userCred, provider, &localStorages[i], remoteStorages[i], syncRange.Xor) if err != nil { - log.Errorf("syncStorageCaches for storage %s(%s) error: %v", localStorages[i].Name, localStorages[i].Id, err) + log.Errorf("syncStorageCaches for storage %s(%s) provider %s error: %v", localStorages[i].Name, localStorages[i].Id, provider.Name, err) } if cachePair.isValid() { newCacheIds = append(newCacheIds, cachePair) @@ -907,8 +919,8 @@ func syncStorageDisks(ctx context.Context, userCred mcclient.TokenCredential, sy return remoteStorage.GetIDisks() }() if err != nil { - msg := fmt.Sprintf("GetIDisks for storage %s failed %s", remoteStorage.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIDisks for storage %s provider %s failed %s", remoteStorage.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } _, _, result := func() ([]SDisk, []cloudprovider.ICloudDisk, compare.SyncResult) { @@ -919,8 +931,8 @@ func syncStorageDisks(ctx context.Context, userCred mcclient.TokenCredential, sy syncResults.Add(DiskManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncDisks for storage %s result: %s", localStorage.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncDisks for storage %s provider %s result: %s", localStorage.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -943,8 +955,8 @@ func syncZoneHosts( return remoteZone.GetIHosts() }() if err != nil { - msg := fmt.Sprintf("GetIHosts for zone %s failed %s", remoteZone.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIHosts for zone %s provider %s failed %s", remoteZone.GetName(), provider.Name, err) + log.Errorf("%s", msg) return nil } localHosts, remoteHosts, result := func() ([]SHost, []cloudprovider.ICloudHost, compare.SyncResult) { @@ -955,8 +967,8 @@ func syncZoneHosts( syncResults.Add(HostManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncHosts for zone %s result: %s", localZone.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncHosts for zone %s provider %s result: %s", localZone.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return nil @@ -992,8 +1004,8 @@ func syncHostStorages(ctx context.Context, userCred mcclient.TokenCredential, sy return remoteHost.GetIStorages() }() if err != nil { - msg := fmt.Sprintf("GetIStorages for host %s failed %s", remoteHost.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIStorages for host %s provider %s failed %s", remoteHost.GetName(), provider.Name, err) + log.Errorf("%s", msg) return nil } localStorages, remoteStorages, result := func() ([]SStorage, []cloudprovider.ICloudStorage, compare.SyncResult) { @@ -1004,8 +1016,8 @@ func syncHostStorages(ctx context.Context, userCred mcclient.TokenCredential, sy syncResults.Add(HoststorageManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncHostStorages for host %s result: %s", localHost.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncHostStorages for host %s provider %s result: %s", localHost.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return nil @@ -1071,8 +1083,8 @@ func syncHostVMs(ctx context.Context, userCred mcclient.TokenCredential, syncRes return remoteHost.GetIVMs() }() if err != nil { - msg := fmt.Sprintf("GetIVMs for host %s failed %s", remoteHost.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIVMs for host %s provider %s failed %s", remoteHost.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -1084,8 +1096,8 @@ func syncHostVMs(ctx context.Context, userCred mcclient.TokenCredential, syncRes syncResults.Add(GuestManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncHostVMs for host %s result: %s", localHost.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncHostVMs for host %s provider %s result: %s", localHost.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) for i := 0; i < len(syncVMPairs); i += 1 { @@ -1163,8 +1175,8 @@ func syncVMNics( } result := localVM.SyncVMNics(ctx, userCred, host, nics, nil) msg := result.Result() - notes := fmt.Sprintf("syncVMNics for VM %s result: %s", localVM.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("syncVMNics for VM %s provider %s result: %s", localVM.Name, provider.Name, msg) + log.Infof("%s", notes) if result.IsError() { return result.AllError() } @@ -1186,8 +1198,8 @@ func syncVMDisks( } result := localVM.SyncVMDisks(ctx, userCred, driver, host, disks, provider.GetOwnerId()) msg := result.Result() - notes := fmt.Sprintf("syncVMDisks for VM %s result: %s", localVM.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("syncVMDisks for VM %s provider %s result: %s", localVM.Name, provider.Name, msg) + log.Infof("%s", notes) if result.IsError() { return result.AllError() } @@ -1201,7 +1213,7 @@ func syncVMEip(ctx context.Context, userCred mcclient.TokenCredential, provider } result := localVM.SyncVMEip(ctx, userCred, provider, eip, provider.GetOwnerId()) msg := result.Result() - log.Infof("syncVMEip for VM %s result: %s", localVM.Name, msg) + log.Infof("syncVMEip for VM %s provider %s result: %s", localVM.Name, provider.Name, msg) if result.IsError() { return result.AllError() } @@ -1260,8 +1272,8 @@ func syncRegionDBInstances( return remoteRegion.GetIDBInstances() }() if err != nil { - msg := fmt.Sprintf("GetIDBInstances for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIDBInstances for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } localInstances, remoteInstances, result := func() ([]SDBInstance, []cloudprovider.ICloudDBInstance, compare.SyncResult) { @@ -1273,8 +1285,8 @@ func syncRegionDBInstances( DBInstanceManager.SyncDBInstanceMasterId(ctx, userCred, provider, instances) msg := result.Result() - notes := fmt.Sprintf("SyncDBInstances for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncDBInstances for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -1303,8 +1315,8 @@ func syncDBInstanceSkus(ctx context.Context, userCred mcclient.TokenCredential, if errors.Cause(err) == cloudprovider.ErrNotImplemented { return } - msg := fmt.Sprintf("GetIDBInstanceSkus for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIDBInstanceSkus for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := func() compare.SyncResult { @@ -1315,8 +1327,8 @@ func syncDBInstanceSkus(ctx context.Context, userCred mcclient.TokenCredential, syncResults.Add(DBInstanceSkuManager, result) msg := result.Result() - notes := fmt.Sprintf("sync rds sku for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("sync rds sku for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -1332,8 +1344,8 @@ func syncNATSkus(ctx context.Context, userCred mcclient.TokenCredential, syncRes if errors.Cause(err) == cloudprovider.ErrNotImplemented { return } - msg := fmt.Sprintf("GetINatSkus for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetINatSkus for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := func() compare.SyncResult { @@ -1344,8 +1356,8 @@ func syncNATSkus(ctx context.Context, userCred mcclient.TokenCredential, syncRes syncResults.Add(NatSkuManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncNatSkus for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNatSkus for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -1361,8 +1373,8 @@ func syncCacheSkus(ctx context.Context, userCred mcclient.TokenCredential, syncR if errors.Cause(err) == cloudprovider.ErrNotImplemented { return } - msg := fmt.Sprintf("GetIElasticcacheSkus for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIElasticcacheSkus for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := func() compare.SyncResult { @@ -1373,8 +1385,8 @@ func syncCacheSkus(ctx context.Context, userCred mcclient.TokenCredential, syncR syncResults.Add(ElasticcacheSkuManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncRedisSkus for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncRedisSkus for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -1517,7 +1529,7 @@ func syncRegionDBInstanceBackups( syncResults.Add(DBInstanceBackupManager, result) msg := result.Result() - log.Infof("SyncDBInstanceBackups for region %s result: %s", localRegion.Name, msg) + log.Infof("SyncDBInstanceBackups for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) if result.IsError() { return result.AllError() } @@ -1609,8 +1621,8 @@ func syncWafIPSets( if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { return nil } - msg := fmt.Sprintf("GetICloudWafIPSets for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudWafIPSets for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } @@ -1620,8 +1632,8 @@ func syncWafIPSets( }() syncResults.Add(WafIPSetManager, result) - notes := fmt.Sprintf("SyncWafIPSets for region %s result: %s", localRegion.Name, result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("SyncWafIPSets for region %s provider %s result: %s", localRegion.Name, provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1646,8 +1658,8 @@ func syncWafRegexSets( if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { return nil } - msg := fmt.Sprintf("GetICloudWafRegexSets for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudWafRegexSets for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } result := func() compare.SyncResult { @@ -1655,8 +1667,8 @@ func syncWafRegexSets( return localRegion.SyncWafRegexSets(ctx, userCred, provider, rSets, xor) }() syncResults.Add(WafRegexSetManager, result) - notes := fmt.Sprintf("SyncWafRegexSets for region %s result: %s", localRegion.Name, result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("SyncWafRegexSets for region %s provider %s result: %s", localRegion.Name, provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1678,8 +1690,8 @@ func syncMongoDBs( return remoteRegion.GetICloudMongoDBs() }() if err != nil { - msg := fmt.Sprintf("GetICloudMongoDBs for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudMongoDBs for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } @@ -1689,8 +1701,8 @@ func syncMongoDBs( }() syncResults.Add(MongoDBManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncMongoDBs for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncMongoDBs for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1713,8 +1725,8 @@ func syncElasticSearchs( return remoteRegion.GetIElasticSearchs() }() if err != nil { - msg := fmt.Sprintf("GetIElasticSearchs for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIElasticSearchs for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } @@ -1724,8 +1736,8 @@ func syncElasticSearchs( }() syncResults.Add(ElasticSearchManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncElasticSearchs for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncElasticSearchs for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1747,8 +1759,8 @@ func syncKafkas( return remoteRegion.GetICloudKafkas() }() if err != nil { - msg := fmt.Sprintf("GetICloudKafkas for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudKafkas for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } @@ -1758,8 +1770,8 @@ func syncKafkas( }() syncResults.Add(KafkaManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncKafkas for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncKafkas for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1781,8 +1793,8 @@ func syncApps( return remoteRegion.GetICloudApps() }() if err != nil { - msg := fmt.Sprintf("GetICloudApps for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudApps for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } result := func() compare.SyncResult { @@ -1791,8 +1803,8 @@ func syncApps( }() syncResults.Add(AppManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncApps for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncApps for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1814,8 +1826,8 @@ func syncKubeClusters( return remoteRegion.GetICloudKubeClusters() }() if err != nil { - msg := fmt.Sprintf("GetICloudKubeClusters for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudKubeClusters for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } localClusters, remoteClusters, result := func() ([]SKubeCluster, []cloudprovider.ICloudKubeCluster, compare.SyncResult) { @@ -1824,8 +1836,8 @@ func syncKubeClusters( }() syncResults.Add(KubeClusterManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncKubeClusters for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncKubeClusters for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -1922,8 +1934,8 @@ func syncWafInstances( return remoteRegion.GetICloudWafInstances() }() if err != nil { - msg := fmt.Sprintf("GetICloudWafInstances for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetICloudWafInstances for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } @@ -1933,8 +1945,8 @@ func syncWafInstances( }() syncResults.Add(WafInstanceManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncWafInstances for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncWafInstances for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -2000,8 +2012,11 @@ func syncRegionSnapshots( return remoteRegion.GetISnapshots() }() if err != nil { - msg := fmt.Sprintf("GetISnapshots for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetISnapshots for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -2013,8 +2028,8 @@ func syncRegionSnapshots( syncResults.Add(SnapshotManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncSnapshots for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncSnapshots for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -2035,7 +2050,11 @@ func syncRegionSnapshotPolicies( return remoteRegion.GetISnapshotPolicies() }() if err != nil { - log.Errorf("GetISnapshotPolicies for region %s failed %s", remoteRegion.GetName(), err) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetISnapshotPolicies for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -2045,8 +2064,8 @@ func syncRegionSnapshotPolicies( }() syncResults.Add(SnapshotPolicyManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncSnapshotPolicies for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncSnapshotPolicies for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -2067,8 +2086,11 @@ func syncRegionNetworkInterfaces( return remoteRegion.GetINetworkInterfaces() }() if err != nil { - msg := fmt.Sprintf("GetINetworkInterfaces for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetINetworkInterfaces for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -2079,8 +2101,8 @@ func syncRegionNetworkInterfaces( syncResults.Add(NetworkInterfaceManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncNetworkInterfaces for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncNetworkInterfaces for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return @@ -2095,23 +2117,26 @@ func syncRegionNetworkInterfaces( return } - syncInterfaceAddresses(ctx, userCred, &localInterfaces[i], remoteInterfaces[i]) + syncInterfaceAddresses(ctx, userCred, provider, &localInterfaces[i], remoteInterfaces[i]) }() } } -func syncInterfaceAddresses(ctx context.Context, userCred mcclient.TokenCredential, localInterface *SNetworkInterface, remoteInterface cloudprovider.ICloudNetworkInterface) { +func syncInterfaceAddresses(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, localInterface *SNetworkInterface, remoteInterface cloudprovider.ICloudNetworkInterface) { addresses, err := remoteInterface.GetICloudInterfaceAddresses() if err != nil { - msg := fmt.Sprintf("GetICloudInterfaceAddresses for networkinterface %s failed %s", remoteInterface.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return + } + msg := fmt.Sprintf("GetICloudInterfaceAddresses for networkinterface %s provider %s failed %s", remoteInterface.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } result := NetworkinterfacenetworkManager.SyncInterfaceAddresses(ctx, userCred, localInterface, addresses) msg := result.Result() - notes := fmt.Sprintf("SyncInterfaceAddresses for networkinterface %s result: %s", localInterface.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncInterfaceAddresses for networkinterface %s provider %s result: %s", localInterface.Name, provider.Name, msg) + log.Infof("%s", notes) if result.IsError() { return } @@ -2343,9 +2368,8 @@ func syncPublicCloudProviderInfo( syncResults.Add(CachedimageManager, result) - msg := result.Result() - notes := fmt.Sprintf("syncCloudImages for %s result: %s", storageCachePairs[i].local.GetName(), msg) - log.Infof(notes) + notes := fmt.Sprintf("syncCloudImages for %s provider %s result: %s", storageCachePairs[i].local.GetName(), provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) } } @@ -2383,16 +2407,16 @@ func getZoneForOnPremiseCloudRegion(ctx context.Context, userCred mcclient.Token func syncOnPremiseCloudProviderStorage(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, iregion cloudprovider.ICloudRegion, driver cloudprovider.ICloudProvider, zone *SZone, syncRange *SSyncRange) []sStoragecacheSyncPair { istorages, err := iregion.GetIStorages() if err != nil { - msg := fmt.Sprintf("GetIStorages for provider %s failed %s", provider.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIStorages for zone %s provider %s failed %s", zone.Name, provider.Name, err) + log.Errorf("%s", msg) return nil } localStorages, remoteStorages, result := StorageManager.SyncStorages(ctx, userCred, provider, zone, istorages, syncRange.Xor) syncResults.Add(StorageManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncStorages for provider %s result: %s", provider.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncStorages for zone %s provider %s result: %s", zone.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return nil @@ -2499,9 +2523,8 @@ func syncOnPremiseCloudProviderInfo( syncResults.Add(HostManager, result) - msg := result.Result() - notes := fmt.Sprintf("SyncHosts for provider %s result: %s", provider.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncHosts for zone %s provider %s result: %s", zone.Name, provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) for i := 0; i < len(localHosts); i += 1 { @@ -2529,9 +2552,8 @@ func syncOnPremiseCloudProviderInfo( }() syncResults.Add(CachedimageManager, result) - msg := result.Result() - notes := fmt.Sprintf("syncCloudImages for stroagecache %s result: %s", storageCachePairs[i].local.GetId(), msg) - log.Infof(notes) + notes := fmt.Sprintf("syncCloudImages for stroagecache %s provider %s result: %s", storageCachePairs[i].local.GetId(), provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) // } } @@ -2550,14 +2572,8 @@ func syncHostNics(ctx context.Context, userCred mcclient.TokenCredential, syncRe if syncResults != nil { syncResults.Add(NetInterfaceManager, result) } - msg := result.Result() - notes := fmt.Sprintf("SyncHostExternalNics for host %s result: %s", localHost.Name, msg) - log.Infof(notes) - if result.IsError() { - return - } else { - log.Infof(notes) - } + notes := fmt.Sprintf("SyncHostExternalNics for host %s provider %s result: %s", localHost.Name, provider.Name, result.Result()) + log.Infof("%s", notes) } func (manager *SCloudproviderregionManager) fetchRecordsByQuery(q *sqlchemy.SQuery) []SCloudproviderregion { @@ -2754,8 +2770,8 @@ func syncInterVpcNetworks(ctx context.Context, userCred mcclient.TokenCredential return errors.Wrapf(err, "GetICloudInterVpcNetworks") } localNetwork, remoteNetwork, result := provider.SyncInterVpcNetwork(ctx, userCred, networks, xor) - notes := fmt.Sprintf("Sync inter vpc network for cloudprovider %s result: %s", provider.GetName(), result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("Sync inter vpc network for provider %s result: %s", provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) for i := range localNetwork { lockman.LockObject(ctx, &localNetwork[i]) @@ -2775,8 +2791,8 @@ func syncDnsZones(ctx context.Context, userCred mcclient.TokenCredential, syncRe return errors.Wrapf(err, "GetICloudInterVpcNetworks") } localZones, remoteZones, result := provider.SyncDnsZones(ctx, userCred, dnsZones, xor) - notes := fmt.Sprintf("Sync dns zones for cloudaccount %s result: %s", provider.Name, result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("Sync dns zones for provider %s result: %s", provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) for i := range localZones { lockman.LockObject(ctx, &localZones[i]) @@ -2800,8 +2816,8 @@ func syncGlobalVpcs(ctx context.Context, userCred mcclient.TokenCredential, sync } localVpcs, remoteVpcs, result := provider.SyncGlobalVpcs(ctx, userCred, gvpcs, xor) - notes := fmt.Sprintf("Sync global vpcs for cloudprovider %s result: %s", provider.GetName(), result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("Sync global vpcs for provider %s result: %s", provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) for i := range localVpcs { @@ -2817,8 +2833,8 @@ func syncGlobalVpcs(ctx context.Context, userCred mcclient.TokenCredential, sync continue } result := localVpcs[i].SyncSecgroups(ctx, userCred, secgroups, xor) - notes := fmt.Sprintf("Sync security group for global vpc %s result: %s", localVpcs[i].Name, result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("Sync security group for global vpc %s provider %s result: %s", localVpcs[i].Name, provider.Name, result.Result()) + log.Infof("%s", notes) } return nil @@ -2838,8 +2854,11 @@ func syncTablestore( return remoteRegion.GetICloudTablestores() }() if err != nil { - msg := fmt.Sprintf("GetICloudTablestores for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return nil + } + msg := fmt.Sprintf("GetICloudTablestores for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return err } result := func() compare.SyncResult { @@ -2848,8 +2867,8 @@ func syncTablestore( }() syncResults.Add(TablestoreManager, result) msg := result.Result() - notes := fmt.Sprintf("SyncTablestores for region %s result: %s", localRegion.Name, msg) - log.Infof(notes) + notes := fmt.Sprintf("SyncTablestores for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) if result.IsError() { return result.AllError() @@ -2873,8 +2892,8 @@ func syncModelartsPools( return err } result := localRegion.SyncModelartsPools(ctx, userCred, provider, ipools, xor) - notes := fmt.Sprintf("SyncModelartsPools for region %s result: %s", provider.GetName(), result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("SyncModelartsPools for provider %s result: %s", provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) return nil } @@ -2890,13 +2909,16 @@ func syncModelartsPoolSkus( ) error { ipools, err := remoteRegion.GetIModelartsPoolSku() if err != nil { - msg := fmt.Sprintf("GetIModelartsPoolSku for provider %s failed %s", err, ipools) - log.Errorf(msg) + if errors.Cause(err) == cloudprovider.ErrNotImplemented || errors.Cause(err) == cloudprovider.ErrNotSupported { + return nil + } + msg := fmt.Sprintf("GetIModelartsPoolSku for provider %s provider %s failed %s", provider.Name, err, ipools) + log.Errorf("%s", msg) return err } result := localRegion.SyncModelartsPoolSkus(ctx, userCred, provider, ipools, xor) - notes := fmt.Sprintf("SyncModelartsPoolSkus for region %s result: %s", provider.GetName(), result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("SyncModelartsPoolSkus for provider %s result: %s", provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) return nil } @@ -2917,8 +2939,8 @@ func syncMiscResources( return err } result := localRegion.SyncMiscResources(ctx, userCred, provider, exts, xor) - notes := fmt.Sprintf("SyncMiscResources for provider %s result: %s", provider.GetName(), result.Result()) - log.Infof(notes) + notes := fmt.Sprintf("SyncMiscResources for provider %s result: %s", provider.Name, result.Result()) + log.Infof("%s", notes) provider.SyncError(result, notes, userCred) return nil } diff --git a/pkg/compute/models/cloudsyncelasticcache.go b/pkg/compute/models/cloudsyncelasticcache.go index 9021e2edba..319c4eba2f 100644 --- a/pkg/compute/models/cloudsyncelasticcache.go +++ b/pkg/compute/models/cloudsyncelasticcache.go @@ -43,8 +43,8 @@ func syncElasticcaches( return remoteRegion.GetIElasticcaches() }() if err != nil { - msg := fmt.Sprintf("GetIElasticcaches for region %s failed %s", remoteRegion.GetName(), err) - log.Errorf(msg) + msg := fmt.Sprintf("GetIElasticcaches for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) + log.Errorf("%s", msg) return } @@ -56,7 +56,7 @@ func syncElasticcaches( syncResults.Add(ElasticcacheManager, result) msg := result.Result() - log.Infof("SyncElasticcaches for region %s result: %s", localRegion.Name, msg) + log.Infof("SyncElasticcaches for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) if result.IsError() { return } diff --git a/pkg/compute/models/cloudsyncelb.go b/pkg/compute/models/cloudsyncelb.go index ca8af0f1ac..4918dff16b 100644 --- a/pkg/compute/models/cloudsyncelb.go +++ b/pkg/compute/models/cloudsyncelb.go @@ -42,7 +42,7 @@ func syncRegionLoadbalancerCertificates( return remoteRegion.GetILoadBalancerCertificates() }() if err != nil { - msg := fmt.Sprintf("GetILoadBalancerCertificates for region %s failed %s", remoteRegion.GetName(), err) + msg := fmt.Sprintf("GetILoadBalancerCertificates for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) log.Errorln(msg) return } @@ -54,7 +54,7 @@ func syncRegionLoadbalancerCertificates( syncResults.Add(LoadbalancerCertificateManager, result) msg := result.Result() - log.Infof("SyncLoadbalancerCertificates for region %s result: %s", localRegion.Name, msg) + log.Infof("SyncLoadbalancerCertificates for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) if result.IsError() { return } @@ -74,7 +74,7 @@ func syncRegionLoadbalancerAcls( return remoteRegion.GetILoadBalancerAcls() }() if err != nil { - msg := fmt.Sprintf("GetILoadBalancerAcls for region %s failed %s", remoteRegion.GetName(), err) + msg := fmt.Sprintf("GetILoadBalancerAcls for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) log.Errorln(msg) return } @@ -86,7 +86,7 @@ func syncRegionLoadbalancerAcls( syncResults.Add(LoadbalancerAclManager, result) msg := result.Result() - log.Infof("SyncLoadbalancerAcls for region %s result: %s", localRegion.Name, msg) + log.Infof("SyncLoadbalancerAcls for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) if result.IsError() { return } @@ -106,7 +106,7 @@ func syncRegionLoadbalancers( return remoteRegion.GetILoadBalancers() }() if err != nil { - msg := fmt.Sprintf("GetILoadBalancers for region %s failed %s", remoteRegion.GetName(), err) + msg := fmt.Sprintf("GetILoadBalancers for region %s provider %s failed %s", remoteRegion.GetName(), provider.Name, err) log.Errorln(msg) return } @@ -118,7 +118,7 @@ func syncRegionLoadbalancers( syncResults.Add(LoadbalancerManager, result) msg := result.Result() - log.Infof("SyncLoadbalancers for region %s result: %s", localRegion.Name, msg) + log.Infof("SyncLoadbalancers for region %s provider %s result: %s", localRegion.Name, provider.Name, msg) if result.IsError() { return } @@ -138,20 +138,20 @@ func syncRegionLoadbalancers( func syncLbPeripherals(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, local *SLoadbalancer, remote cloudprovider.ICloudLoadbalancer) { err := syncLoadbalancerEip(ctx, userCred, provider, local, remote) if err != nil { - log.Errorf("syncLoadbalancerEip error %s", err) + log.Errorf("syncLoadbalancerEips for loadbalancer %s provider %s error %s", local.Name, provider.Name, err) } err = syncLoadbalancerBackendgroups(ctx, userCred, SSyncResultSet{}, provider, local, remote) if err != nil { - log.Errorf("syncLoadbalancerBackendgroups error: %v", err) + log.Errorf("syncLoadbalancerBackendgroups for loadbalancer %s provider %s error: %v", local.Name, provider.Name, err) } err = syncLoadbalancerListeners(ctx, userCred, SSyncResultSet{}, provider, local, remote) if err != nil { - log.Errorf("syncLoadbalancerListeners error: %v", err) + log.Errorf("syncLoadbalancerListeners for loadbalancer %s provider %s error: %v", local.Name, provider.Name, err) } err = syncLoadbalancerSecurityGroups(ctx, userCred, local, remote) if err != nil { - log.Errorf("syncLoadbalancerSecurityGroups error: %v", err) + log.Errorf("syncLoadbalancerSecurityGroups for loadbalancer %s provider %s error: %v", local.Name, provider.Name, err) } } @@ -176,7 +176,7 @@ func syncLoadbalancerEip(ctx context.Context, userCred mcclient.TokenCredential, } result := localLb.SyncLoadbalancerEip(ctx, userCred, provider, eip) msg := result.Result() - log.Infof("SyncEip for Loadbalancer %s result: %s", localLb.Name, msg) + log.Infof("SyncEips for Loadbalancer %s provider %s result: %s", localLb.Name, provider.Name, msg) if result.IsError() { return result.AllError() } @@ -193,7 +193,7 @@ func syncLoadbalancerListeners(ctx context.Context, userCred mcclient.TokenCrede syncResults.Add(LoadbalancerListenerManager, result) msg := result.Result() - log.Infof("SyncLoadbalancerListeners for loadbalancer %s result: %s", localLoadbalancer.Name, msg) + log.Infof("SyncLoadbalancerListeners for loadbalancer %s provider %s result: %s", localLoadbalancer.Name, provider.Name, msg) if result.IsError() { return result.AllError() } @@ -211,7 +211,7 @@ func syncLoadbalancerListeners(ctx context.Context, userCred mcclient.TokenCrede func syncLoadbalancerListenerRules(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, provider *SCloudprovider, localListener *SLoadbalancerListener, remoteListener cloudprovider.ICloudLoadbalancerListener) { remoteRules, err := remoteListener.GetILoadbalancerListenerRules() if err != nil { - msg := fmt.Sprintf("GetILoadbalancerListenerRules for listener %s failed %s", localListener.Name, err) + msg := fmt.Sprintf("GetILoadbalancerListenerRules for listener %s provider %s failed %s", localListener.Name, provider.Name, err) log.Errorln(msg) return } @@ -220,7 +220,7 @@ func syncLoadbalancerListenerRules(ctx context.Context, userCred mcclient.TokenC syncResults.Add(LoadbalancerListenerRuleManager, result) msg := result.Result() - log.Infof("SyncLoadbalancerListenerRules for listener %s result: %s", localListener.Name, msg) + log.Infof("SyncLoadbalancerListenerRules for listener %s provider %s result: %s", localListener.Name, provider.Name, msg) if result.IsError() { return } @@ -235,7 +235,7 @@ func syncLoadbalancerBackendgroups(ctx context.Context, userCred mcclient.TokenC syncResults.Add(LoadbalancerBackendGroupManager, result) msg := result.Result() - log.Infof("SyncLoadbalancerBackendgroups for loadbalancer %s result: %s", local.Name, msg) + log.Infof("SyncLoadbalancerBackendgroups for loadbalancer %s provider %s result: %s", local.Name, provider.Name, msg) if result.IsError() { return result.AllError() }