diff --git a/pkg/compute/models/cloudsync.go b/pkg/compute/models/cloudsync.go index e265047e7b..02ea57c88e 100644 --- a/pkg/compute/models/cloudsync.go +++ b/pkg/compute/models/cloudsync.go @@ -127,14 +127,16 @@ func syncRegionSkus(ctx context.Context, userCred mcclient.TokenCredential, loca } } - cnt, err = ElasticcacheSkuManager.GetSkuCountByRegion(regionId) - if err != nil { - log.Errorf("ElasticcacheSkuManager.GetSkuCountByRegion fail %s", err) - return - } + if localRegion.GetDriver().IsSupportedElasticcache() { + cnt, err = ElasticcacheSkuManager.GetSkuCountByRegion(regionId) + if err != nil { + log.Errorf("ElasticcacheSkuManager.GetSkuCountByRegion fail %s", err) + return + } - if cnt == 0 { - syncElasticCacheSkusByRegion(ctx, userCred, localRegion) + if cnt == 0 { + syncElasticCacheSkusByRegion(ctx, userCred, localRegion) + } } } diff --git a/pkg/compute/models/regiondrivers.go b/pkg/compute/models/regiondrivers.go index 7388cfde20..eb0cc4c84b 100644 --- a/pkg/compute/models/regiondrivers.go +++ b/pkg/compute/models/regiondrivers.go @@ -142,6 +142,7 @@ type IRegionDriver interface { } type IElasticcacheDriver interface { + IsSupportedElasticcache() bool AllowCreateElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *SElasticcache) error AllowUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *SElasticcache) error ValidateCreateElasticcacheData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) diff --git a/pkg/compute/regiondrivers/aliyun.go b/pkg/compute/regiondrivers/aliyun.go index 76373826b9..2462950756 100644 --- a/pkg/compute/regiondrivers/aliyun.go +++ b/pkg/compute/regiondrivers/aliyun.go @@ -1535,3 +1535,7 @@ func (self *SAliyunRegionDriver) RequestElasticcacheAccountResetPassword(ctx con return ea.SyncWithCloudElasticcacheAccount(ctx, userCred, iea) } + +func (self *SAliyunRegionDriver) IsSupportedElasticcache() bool { + return true +} diff --git a/pkg/compute/regiondrivers/base.go b/pkg/compute/regiondrivers/base.go index 48022676fc..fb8ce4dafd 100644 --- a/pkg/compute/regiondrivers/base.go +++ b/pkg/compute/regiondrivers/base.go @@ -294,3 +294,7 @@ func (self *SBaseRegionDriver) ValidateResetDBInstancePassword(ctx context.Conte func (self *SBaseRegionDriver) IsSupportKeepDBInstanceManualBackup() bool { return false } + +func (self *SBaseRegionDriver) IsSupportedElasticcache() bool { + return false +} diff --git a/pkg/compute/regiondrivers/huawei.go b/pkg/compute/regiondrivers/huawei.go index 49d06f7bb4..d7e1a5dde2 100644 --- a/pkg/compute/regiondrivers/huawei.go +++ b/pkg/compute/regiondrivers/huawei.go @@ -2562,3 +2562,7 @@ func (self *SHuaWeiRegionDriver) AllowCreateElasticcacheBackup(ctx context.Conte func (self *SHuaWeiRegionDriver) AllowUpdateElasticcacheAuthMode(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, elasticcache *models.SElasticcache) error { return fmt.Errorf("not support update huawei elastic cache auth_mode") } + +func (self *SHuaWeiRegionDriver) IsSupportedElasticcache() bool { + return true +}