Skip to content

Commit

Permalink
fix(region): skip sync meta if no public cloud register (#18827)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Nov 30, 2023
1 parent df71fdd commit a5c5f4f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/compute/models/cloudimages.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func SyncPublicCloudImages(ctx context.Context, userCred mcclient.TokenCredentia
return
}

if len(regions) == 0 {
return
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
log.Errorf("FetchYunionmeta %v", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/compute/models/dbinstance_skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,9 @@ func SyncRegionDBInstanceSkus(ctx context.Context, userCred mcclient.TokenCreden
log.Errorf("failed to fetch cloudregions: %v", err)
return
}
if len(cloudregions) == 0 {
return
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion pkg/compute/models/elasticcache_skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ func SyncElasticCacheSkus(ctx context.Context, userCred mcclient.TokenCredential
return
}
}
cloudregions := fetchSkuSyncCloudregions()
if len(cloudregions) == 0 {
return
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
Expand All @@ -819,7 +823,6 @@ func SyncElasticCacheSkus(ctx context.Context, userCred mcclient.TokenCredential
return
}

cloudregions := fetchSkuSyncCloudregions()
for i := range cloudregions {
region := &cloudregions[i]

Expand Down
4 changes: 4 additions & 0 deletions pkg/compute/models/nas_skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ func SyncRegionNasSkus(ctx context.Context, userCred mcclient.TokenCredential, r
return errors.Wrapf(err, "db.FetchModelObjects")
}

if len(regions) == 0 {
return nil
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
return errors.Wrapf(err, "FetchYunionmeta")
Expand Down
3 changes: 3 additions & 0 deletions pkg/compute/models/nat_skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ func SyncRegionNatSkus(ctx context.Context, userCred mcclient.TokenCredential, r
if err != nil {
return errors.Wrapf(err, "db.FetchModelObjects")
}
if len(regions) == 0 {
return nil
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion pkg/compute/models/server_skus.go
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,10 @@ func SyncServerSkus(ctx context.Context, userCred mcclient.TokenCredential, isSt
return
}
}
cloudregions := fetchSkuSyncCloudregions()
if len(cloudregions) == 0 {
return
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
Expand All @@ -1613,7 +1617,6 @@ func SyncServerSkus(ctx context.Context, userCred mcclient.TokenCredential, isSt
return
}

cloudregions := fetchSkuSyncCloudregions()
for i := range cloudregions {
region := &cloudregions[i]

Expand Down
4 changes: 4 additions & 0 deletions pkg/compute/models/waf_rule_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ func SyncWafGroups(ctx context.Context, userCred mcclient.TokenCredential, isSta
return errors.Wrapf(err, "fetchCloudEnvs")
}

if len(cloudEnvs) == 0 {
return nil
}

meta, err := yunionmeta.FetchYunionmeta(ctx)
if err != nil {
return errors.Wrapf(err, "FetchYunionmeta")
Expand Down

0 comments on commit a5c5f4f

Please sign in to comment.