Skip to content

Commit

Permalink
fix(console): gpu monitor unit display wrong and another bug (#2039)
Browse files Browse the repository at this point in the history
* fix(console): change gpu monitor unit

* fix(console): add tips for AuditSetting

* fix(console): rm tag length validate

* fix(console): create notiftemplate fail

* fix(console): add timeout as 3 min
  • Loading branch information
jo-hnny authored Jul 28, 2022
1 parent 11f93ec commit b757733
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 48 deletions.
17 changes: 9 additions & 8 deletions web/console/helpers/reduceNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ import { parseQueryString } from './urlUtil';
import { getProjectName } from './appUtil';

/** 是否展示没有权限的弹窗 */
export let Init_Forbiddent_Config = {
export const Init_Forbiddent_Config = {
isShow: false,
message: ''
};
/** 获取当前的uuid */

export const uuid = () => {
let s = [];
let hexDigits = '0123456789abcdef';
const s = [];
const hexDigits = '0123456789abcdef';
for (let i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = '-';

let uuid = s.join('');
const uuid = s.join('');
return uuid;
};

Expand Down Expand Up @@ -81,7 +81,7 @@ export const requestMethodForAction = (type: string) => {
update: Method.patch
};

let method = mapMethod[type] ? mapMethod[type] : 'get';
const method = mapMethod[type] ? mapMethod[type] : 'get';

return method;
};
Expand Down Expand Up @@ -157,7 +157,8 @@ export const reduceNetworkRequest = async (
'Content-Type': 'application/json'
},
userDefinedHeader
)
),
timeout: 3 * 60 * 1000
};

if (data) {
Expand All @@ -178,7 +179,7 @@ export const reduceNetworkRequest = async (
});
throw error;
} else if (error.response === undefined) {
let uuid =
const uuid =
error.config && error.config.headers && error.config.headers['X-Remote-Extra-RequestID']
? error.config.headers['X-Remote-Extra-RequestID']
: '';
Expand All @@ -194,7 +195,7 @@ export const reduceNetworkRequest = async (
}

// 处理回报请求
let response = reduceNetworkResponse(rsp);
const response = reduceNetworkResponse(rsp);
return response;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Base64 } from 'js-base64';

import { allActions } from '../actions';
import { configTest, updateStoreConfig, getStoreConfig } from '../WebAPI';
import { t } from '@/tencent/tea-app/lib/i18n';

const { useState, useEffect, useReducer } = React;

Expand Down Expand Up @@ -280,7 +281,10 @@ export const AuditSetting = props => {
</Form.Item>
)}
/>
<Form.Item message={getConnectionStatusMessage(auditSetting.connectionState)}>
<Form.Item
message={getConnectionStatusMessage(auditSetting.connectionState)}
extra={t('请先进行检测连接再点击完成!')}
>
<Button type="primary" onClick={handleSubmit(onConnect)}>
检测连接
</Button>
Expand Down
42 changes: 22 additions & 20 deletions web/console/src/modules/cluster/actions/validatorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ export const validatorActions = {
if (!value) {
status = 2;
message = content + t('不能为空');
} else if (value.length > 63) {
status = 2;
message = content + t('长度不能超过63个字符');
} else if (!reg.test(value)) {
status = 2;
message = content + t('格式不正确');
Expand All @@ -72,10 +69,14 @@ export const validatorActions = {
},
validateComputerLabelValue(Id) {
return (dispatch, getState) => {
let { labelEdition } = getState().subRoot.computerState,
const { labelEdition } = getState().subRoot.computerState,
{ labels } = labelEdition,
eIndex = labels.findIndex(e => e.id === Id);
let result = validatorActions._validateComputerLabelValue(labels[eIndex].value, 'value', labels[eIndex].disabled);
const result = validatorActions._validateComputerLabelValue(
labels[eIndex].value,
'value',
labels[eIndex].disabled
);
labels[eIndex].v_value = result;
dispatch({
type: ActionType.UpdateLabelEdition,
Expand All @@ -85,10 +86,10 @@ export const validatorActions = {
},
validateComputerLabelKey(Id) {
return (dispatch, getState) => {
let { labelEdition } = getState().subRoot.computerState,
const { labelEdition } = getState().subRoot.computerState,
{ labels } = labelEdition,
eIndex = labels.findIndex(e => e.id === Id);
let result = validatorActions._validateComputerLabelValue(labels[eIndex].key, 'key', labels[eIndex].disabled);
const result = validatorActions._validateComputerLabelValue(labels[eIndex].key, 'key', labels[eIndex].disabled);
labels[eIndex].v_key = result;
dispatch({
type: ActionType.UpdateLabelEdition,
Expand All @@ -108,7 +109,7 @@ export const validatorActions = {
},
validateAllComputerLabel() {
return (dispatch, getState) => {
let { labelEdition } = getState().subRoot.computerState,
const { labelEdition } = getState().subRoot.computerState,
{ labels } = labelEdition;
labels.forEach(label => {
dispatch(validatorActions.validateComputerLabelKey(label.id));
Expand All @@ -132,9 +133,6 @@ export const validatorActions = {
if (!value) {
status = 2;
message = content + t('不能为空');
} else if (value.length > 63) {
status = 2;
message = content + t('长度不能超过63个字符');
} else if (!reg.test(value)) {
status = 2;
message = content + t('格式不正确');
Expand All @@ -151,10 +149,14 @@ export const validatorActions = {
},
validateComputerTaintValue(Id) {
return (dispatch, getState: GetState) => {
let { taintEdition } = getState().subRoot.computerState,
const { taintEdition } = getState().subRoot.computerState,
{ taints } = taintEdition,
eIndex = taints.findIndex(e => e.id === Id);
let result = validatorActions._validateComputerTaintValue(taints[eIndex].value, 'value', taints[eIndex].disabled);
const result = validatorActions._validateComputerTaintValue(
taints[eIndex].value,
'value',
taints[eIndex].disabled
);
taints[eIndex].v_value = result;
dispatch({
type: ActionType.UpdateTaintEdition,
Expand All @@ -164,10 +166,10 @@ export const validatorActions = {
},
validateComputerTaintKey(Id) {
return (dispatch, getState) => {
let { taintEdition } = getState().subRoot.computerState,
const { taintEdition } = getState().subRoot.computerState,
{ taints } = taintEdition,
eIndex = taints.findIndex(e => e.id === Id);
let result = validatorActions._validateComputerTaintValue(taints[eIndex].key, 'key', taints[eIndex].disabled);
const result = validatorActions._validateComputerTaintValue(taints[eIndex].key, 'key', taints[eIndex].disabled);
taints[eIndex].v_key = result;
dispatch({
type: ActionType.UpdateTaintEdition,
Expand All @@ -187,7 +189,7 @@ export const validatorActions = {
},
validateAllComputerTaint() {
return (dispatch, getState) => {
let { taintEdition } = getState().subRoot.computerState,
const { taintEdition } = getState().subRoot.computerState,
{ taints } = taintEdition;
taints.forEach(taint => {
dispatch(validatorActions.validateComputerTaintKey(taint.id));
Expand Down Expand Up @@ -219,8 +221,8 @@ export const validatorActions = {
},
validateClusterAllocationRatio(type?: string, value?: string) {
return (dispatch, getState: GetState) => {
let { clusterAllocationRatioEdition } = getState().subRoot;
let result = validatorActions._validateClusterAllocationRatio(+value);
const { clusterAllocationRatioEdition } = getState().subRoot;
const result = validatorActions._validateClusterAllocationRatio(+value);
let obj;
if (type === 'cpu') {
obj = {
Expand All @@ -239,7 +241,7 @@ export const validatorActions = {
},
validateAllClusterAllocationRatio() {
return (dispatch, getState: GetState) => {
let {
const {
clusterAllocationRatioEdition: { isUseCpu, isUseMemory, cpuRatio, memoryRatio }
} = getState().subRoot;
isUseCpu && dispatch(validatorActions.validateClusterAllocationRatio('cpu', cpuRatio));
Expand All @@ -248,7 +250,7 @@ export const validatorActions = {
},
_validateAllClusterAllocationRatio(clusterAllocationRatioEdition: AllocationRatioEdition) {
let result = true;
let { isUseCpu, isUseMemory, memoryRatio, cpuRatio } = clusterAllocationRatioEdition;
const { isUseCpu, isUseMemory, memoryRatio, cpuRatio } = clusterAllocationRatioEdition;
if (isUseCpu) {
result = result && validatorActions._validateClusterAllocationRatio(+cpuRatio).status === 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const mapDispatchToProps = dispatch =>
@connect(state => state, mapDispatchToProps)
export class UpdateNodeLabelDialog extends React.Component<RootProps, {}> {
render() {
let { actions, route, subRoot, cluster } = this.props,
const { actions, route, subRoot, cluster } = this.props,
{ computerState } = subRoot,
{ updateNodeLabel, labelEdition } = computerState,
{ labels } = labelEdition;
let canAdd = isEmpty(labels.filter(x => !x.key));
const canAdd = isEmpty(labels.filter(x => !x.key));

return (
<WorkflowDialog
Expand All @@ -63,9 +63,7 @@ export class UpdateNodeLabelDialog extends React.Component<RootProps, {}> {
{t('新增Label')}
</LinkButton>
<p className="form-input-help text-weak">
{t(
'长度不超过63个字符,只能包含字母、数字及"-./",必须以字母或者数字开头结尾,且不能包含"kubernetes"保留字'
)}
{t('只能包含字母、数字及"-./",必须以字母或者数字开头结尾,且不能包含"kubernetes"保留字')}
</p>
</div>
</FormItem>
Expand All @@ -74,7 +72,7 @@ export class UpdateNodeLabelDialog extends React.Component<RootProps, {}> {
}
/** 展示Label的选项 */
private _renderLabelList() {
let { actions, subRoot } = this.props,
const { actions, subRoot } = this.props,
{ labels } = subRoot.computerState.labelEdition;
return labels.map((label, index) => {
return (
Expand Down
8 changes: 4 additions & 4 deletions web/console/src/modules/cluster/models/MonitorPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ const gpuMemFields = table => [
{
expr: `mean(k8s_${table}_gpu_memory_used)`,
alias: t('GPU内存使用量'),
unit: t('块')
unit: 'MiB'
// thousands: 1024, valueLabels:valueLabels1024
},
{
expr: `mean(k8s_${table}_rate_gpu_memory_used_node)`,
alias: t('GPU内存使用量(占节点)'),
unit: t('块')
alias: t('GPU内存使用率(占节点)'),
unit: '%'
},
{
expr: `mean(k8s_${table}_rate_gpu_memory_used_request)`,
Expand Down Expand Up @@ -288,7 +288,7 @@ export const resourceMonitorFields = [
{
expr: 'mean(k8s_workload_gpu_memory_used)',
alias: t('GPU内存使用量'),
unit: t('块')
unit: 'MiB'
// thousands: 1024, valueLabels:valueLabels1024
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { t } from '@tencent/tea-app/lib/i18n';
import { Form } from '@tea/component/form';
import { Input } from '@tea/component/input';
import { onChange } from '../../schema/schemaUtil';
import { Select } from '@tencent/tea-component';
import { Select, Text } from '@tencent/tea-component';
import { EditResource } from './EditResource';
import { templateSchema } from '../../schema/templateSchema';
import { router } from '../../router';
Expand Down Expand Up @@ -79,14 +79,17 @@ export class EditResourceTemplate extends EditResource {
</Form.Item>

<Form.Item label={t('渠道')} required>
<Select
disabled={mode === 'update'}
size="l"
placeholder={t('请选择渠道')}
options={namespaceOptions}
value={resource.properties.metadata.properties.namespace.value}
onChange={onChange(resource.properties.metadata.properties.namespace)}
/>
{mode === 'create' ? (
<Select
size="l"
placeholder={t('请选择渠道')}
options={namespaceOptions}
value={resource.properties.metadata.properties.namespace.value}
onChange={onChange(resource.properties.metadata.properties.namespace)}
/>
) : (
<Text reset>{resource?.properties?.metadata?.properties?.namespace?.value ?? '-'}</Text>
)}
</Form.Item>
{this.renderFields(resource.properties.spec.properties[resource.properties.spec['pick']])}
</Form>
Expand Down

0 comments on commit b757733

Please sign in to comment.