Merge pull request #1752 from touwaeriol/fix/quota-exceeded-scheduling
fix(account): prevent quota-exceeded API key/Bedrock accounts from being scheduled
This commit is contained in:
@@ -284,6 +284,16 @@ const hasError = computed(() => {
|
||||
return props.account.status === 'error'
|
||||
})
|
||||
|
||||
const isQuotaExceeded = computed(() => {
|
||||
const exceeded = (used?: number | null, limit?: number | null) =>
|
||||
typeof limit === 'number' && limit > 0 && typeof used === 'number' && used >= limit
|
||||
return (
|
||||
exceeded(props.account.quota_used, props.account.quota_limit) ||
|
||||
exceeded(props.account.quota_daily_used, props.account.quota_daily_limit) ||
|
||||
exceeded(props.account.quota_weekly_used, props.account.quota_weekly_limit)
|
||||
)
|
||||
})
|
||||
|
||||
// Computed: countdown text for rate limit (429)
|
||||
const rateLimitCountdown = computed(() => {
|
||||
return formatCountdown(props.account.rate_limit_reset_at)
|
||||
@@ -307,19 +317,16 @@ const statusClass = computed(() => {
|
||||
if (isTempUnschedulable.value) {
|
||||
return 'badge-warning'
|
||||
}
|
||||
if (props.account.status !== 'active') {
|
||||
return props.account.status === 'error' ? 'badge-danger' : 'badge-gray'
|
||||
}
|
||||
if (isQuotaExceeded.value) {
|
||||
return 'badge-warning'
|
||||
}
|
||||
if (!props.account.schedulable) {
|
||||
return 'badge-gray'
|
||||
}
|
||||
switch (props.account.status) {
|
||||
case 'active':
|
||||
return 'badge-success'
|
||||
case 'inactive':
|
||||
return 'badge-gray'
|
||||
case 'error':
|
||||
return 'badge-danger'
|
||||
default:
|
||||
return 'badge-gray'
|
||||
}
|
||||
return 'badge-success'
|
||||
})
|
||||
|
||||
// Computed: status text
|
||||
@@ -330,6 +337,12 @@ const statusText = computed(() => {
|
||||
if (isTempUnschedulable.value) {
|
||||
return t('admin.accounts.status.tempUnschedulable')
|
||||
}
|
||||
if (props.account.status !== 'active') {
|
||||
return t(`admin.accounts.status.${props.account.status}`)
|
||||
}
|
||||
if (isQuotaExceeded.value) {
|
||||
return t('admin.accounts.status.quotaExceeded')
|
||||
}
|
||||
if (!props.account.schedulable) {
|
||||
return t('admin.accounts.status.paused')
|
||||
}
|
||||
|
||||
@@ -2126,6 +2126,7 @@ export default {
|
||||
rateLimited: 'Rate Limited',
|
||||
overloaded: 'Overloaded',
|
||||
tempUnschedulable: 'Temp Unschedulable',
|
||||
quotaExceeded: 'Quota Exceeded',
|
||||
unschedulable: 'Unschedulable',
|
||||
rateLimitedUntil: 'Rate limited and removed from scheduling. Auto resumes at {time}',
|
||||
rateLimitedAutoResume: 'Auto resumes in {time}',
|
||||
|
||||
@@ -2315,6 +2315,7 @@ export default {
|
||||
rateLimited: '限流中',
|
||||
overloaded: '过载中',
|
||||
tempUnschedulable: '临时不可调度',
|
||||
quotaExceeded: '配额超限',
|
||||
unschedulable: '不可调度',
|
||||
rateLimitedUntil: '限流中,当前不参与调度,预计 {time} 自动恢复',
|
||||
rateLimitedAutoResume: '{time} 自动恢复',
|
||||
|
||||
Reference in New Issue
Block a user