Merge pull request #5399 from swordqiu/automated-cherry-pick-of-#5398-upstream-release-3.1

Automated cherry pick of #5398: fix: not check domain quota if non_default_domain_project is off
This commit is contained in:
Zexi Li
2020-03-09 12:31:49 +08:00
committed by GitHub
2 changed files with 13 additions and 0 deletions
+2
View File
@@ -28,6 +28,8 @@ type IQuotaKeys interface {
Fields() []string
Values() []string
Compare(IQuotaKeys) int
OwnerId() mcclient.IIdentityProvider
}
type IQuota interface {
+11
View File
@@ -22,6 +22,7 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -220,6 +221,16 @@ func (manager *SQuotaBaseManager) checkQuota(ctx context.Context, request IQuota
func (manager *SQuotaBaseManager) __checkQuota(ctx context.Context, quota IQuota, request IQuota) error {
keys := quota.GetKeys()
if !consts.GetNonDefaultDomainProjects() {
ownerId := keys.OwnerId()
if len(ownerId.GetProjectDomainId()) > 0 && len(ownerId.GetProjectId()) == 0 {
// if non_default_domain_projects == false
// skip domain quota check
return nil
}
}
used := manager.newQuota()
err := manager.usageStore.GetQuota(ctx, keys, used)
if err != nil {