Skip to content

Commit 765d1de

Browse files
author
gitlab
committed
Merge branch 'fix/ZSTAC-82208' into '5.5.6'
<fix>[identity]: skip quota check for admin-type accounts See merge request zstackio/zstack!9160
2 parents 1d41921 + eb4f89d commit 765d1de

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

identity/src/main/java/org/zstack/identity/QuotaUtil.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void checkQuota(Message msg, String currentAccountUuid, String targetAcco
154154
return;
155155
}
156156

157-
if (AccountConstant.isAdminPermission(targetAccountUuid)) {
157+
if (AccountConstant.isAdminPermission(targetAccountUuid) || isAdminAccount(targetAccountUuid)) {
158158
return;
159159
}
160160

@@ -217,11 +217,18 @@ private void checkFunctionalSizeRequest(Message msg,
217217
return;
218218
}
219219

220+
Quota.QuotaPair pair = pairs.get(requiredRequest.getQuotaName());
221+
if (pair == null) {
222+
logger.warn(String.format("quota[name: %s] not defined for account[uuid: %s], skip check",
223+
requiredRequest.getQuotaName(), targetAccountUuid));
224+
return;
225+
}
226+
220227
QuotaUtil.QuotaCompareInfo quotaCompareInfo = new QuotaUtil.QuotaCompareInfo();
221228
quotaCompareInfo.currentAccountUuid = currentAccountUuid;
222229
quotaCompareInfo.resourceTargetOwnerAccountUuid = targetAccountUuid;
223230
quotaCompareInfo.quotaName = requiredRequest.getQuotaName();
224-
quotaCompareInfo.quotaValue = pairs.get(requiredRequest.getQuotaName()).getValue();
231+
quotaCompareInfo.quotaValue = pair.getValue();
225232
quotaCompareInfo.currentUsed = used;
226233
quotaCompareInfo.request = asked;
227234
CheckQuota(quotaCompareInfo);
@@ -235,13 +242,19 @@ private void checkFixedSizeRequest(FixedSizeRequiredRequest fixedSizeRequiredReq
235242
return;
236243
}
237244

245+
Quota.QuotaPair pair = pairs.get(fixedSizeRequiredRequest.getQuotaName());
246+
if (pair == null) {
247+
logger.warn(String.format("quota[name: %s] not defined for account[uuid: %s], skip check",
248+
fixedSizeRequiredRequest.getQuotaName(), targetAccountUuid));
249+
return;
250+
}
251+
238252
QuotaUtil.QuotaCompareInfo quotaCompareInfo = new QuotaUtil.QuotaCompareInfo();
239253
quotaCompareInfo.currentAccountUuid = currentAccountUuid;
240254
quotaCompareInfo.resourceTargetOwnerAccountUuid = targetAccountUuid;
241255
quotaCompareInfo.quotaName = fixedSizeRequiredRequest.getQuotaName();
242-
Quota.QuotaPair pair = pairs.get(fixedSizeRequiredRequest.getQuotaName());
243256
logger.debug("get quota pair of " + fixedSizeRequiredRequest.getQuotaName() + ":\n" + JSONObjectUtil.toJsonString(pair));
244-
quotaCompareInfo.quotaValue = pairs.get(fixedSizeRequiredRequest.getQuotaName()).getValue();
257+
quotaCompareInfo.quotaValue = pair.getValue();
245258
quotaCompareInfo.currentUsed = used;
246259
quotaCompareInfo.request = asked;
247260
CheckQuota(quotaCompareInfo);

0 commit comments

Comments
 (0)