Skip to content

Commit eb44cdd

Browse files
authored
fix(region): allow delete server sku (#23693)
1 parent c696796 commit eb44cdd

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

pkg/compute/models/server_skus.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ func sliceToJsonObject(items []int) jsonutils.JSONObject {
193193
return ret
194194
}
195195

196-
func inWhiteList(provider string) bool {
197-
// 私有云套餐也允许更新删除
198-
return provider == api.CLOUD_PROVIDER_ONECLOUD || utils.IsInStringArray(provider, api.PRIVATE_CLOUD_PROVIDERS)
199-
}
200-
201196
func genInstanceType(family string, cpu, memMb int64) (string, error) {
202197
if cpu <= 0 {
203198
return "", fmt.Errorf("cpu_core_count should great than zero")
@@ -679,9 +674,10 @@ func (self *SServerSku) ValidateDeleteCondition(ctx context.Context, info *api.S
679674
return httperrors.NewNotEmptyError("now allow to delete inuse instance_type.please remove related servers first: %s", self.Name)
680675
}
681676

682-
if !inWhiteList(self.Provider) {
677+
if !options.Options.EnableDeletePublicCloudSku && utils.IsInStringArray(self.Provider, api.PUBLIC_CLOUD_PROVIDERS) {
683678
return httperrors.NewForbiddenError("not allow to delete public cloud instance_type: %s", self.Name)
684679
}
680+
685681
return nil
686682
}
687683

pkg/compute/options/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ type ComputeOptions struct {
117117
ServerSkuSyncIntervalMinutes int `default:"60" help:"Interval to sync public cloud server skus, defualt is 1 hour"`
118118
SkuBatchSync int `default:"5" help:"How many skus can be sync in a batch"`
119119

120+
EnableDeletePublicCloudSku bool `help:"Enable delete public cloud sku" default:"true"`
120121
// sku sync
121122
SyncSkusDay int `default:"1" help:"Days auto sync skus data, default 1 day"`
122123
SyncSkusHour int `default:"3" help:"What hour start sync skus, default 03:00"`

0 commit comments

Comments
 (0)