Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Incorrect information for exceeding the resource limit #2809

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module.exports = {
'Invalid name. The name can contain only lowercase letters, numbers, and hyphens (-), and must start and end with a lowercase letter or number. The maximum length is 63 characters.',
NO_IMAGE_FOUND: 'No Image Found',
CONTAINER_EMPTY_DESC: 'Please add at least one container.',
QUOTA_UNSET_TIP: 'Resource occupation is unset',
QUOTA_OVERCOST_TIP:
'The current resource occupation has exceeded the remaining',

// List > Create > Pod Settings > Port Settings
WORKLOAD_PORT_NAME_DESC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,23 @@ export default class QuotaCheck extends Component {
if (isEmpty(containers) && isEmpty(initContainers)) {
return null
}
const limitUnset = Object.values(checkResult).some(
item => item.overcost === 'unset'
)
const overcost = Object.values(checkResult).some(
item => item.overcost === true
)
const type = overcost || limitUnset ? 'error' : 'info'
const title = overcost
? t('QUOTA_OVERCOST_TIP')
: limitUnset
? t('QUOTA_UNSET_TIP')
: t('Remaining Quota')

const overcost = Object.values(checkResult).some(item => item.overcost)
const type = overcost ? 'error' : 'info'
const title = overcost ? t('QUOTA_OVERCOST_TIP') : t('Remaining Quota')

const message = overcost
? this.renderOverCostMessage(checkResult)
: this.renderQuotaMessage(checkResult)
const message =
overcost || limitUnset
? this.renderOverCostMessage(checkResult)
: this.renderQuotaMessage(checkResult)

return (
<Alert
Expand Down
5 changes: 4 additions & 1 deletion src/utils/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ export const compareQuotaAndResources = (leftQuota, resources) => {
namespaceQuota === Infinity ? undefined : `${namespaceQuota}${unit}`,
workspaceQuota:
workspaceQuota === Infinity ? undefined : `${workspaceQuota}${unit}`,
overcost: cost > workspaceQuota || cost > namespaceQuota,
overcost:
cost === Infinity
? 'unset'
: cost > workspaceQuota || cost > namespaceQuota,
}
})

Expand Down