From 10228087effc3a613a6146605965f1d61d5cc4e2 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 26 May 2022 14:20:13 +0800 Subject: [PATCH] =?UTF-8?q?revert(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20K8S=E8=B5=84=E6=BA=90=E6=B1=A0=E6=89=BE=E5=9B=9EnodeSelector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/system/TestResourcePool.vue | 37 ++++++++++++++++++- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/settings/system/TestResourcePool.vue b/frontend/src/business/components/settings/system/TestResourcePool.vue index 41ba74b135..df1e89249f 100644 --- a/frontend/src/business/components/settings/system/TestResourcePool.vue +++ b/frontend/src/business/components/settings/system/TestResourcePool.vue @@ -172,6 +172,21 @@ + + + + + + + + @@ -390,11 +405,12 @@ export default { if (this.infoList.length <= 0) { return {validate: false, msg: this.$t('test_resource_pool.cannot_empty')}; } + let resourcePoolType = this.form.type; let resultValidate = {validate: true, msg: this.$t('test_resource_pool.fill_the_data')}; this.infoList.forEach(info => { for (let key in info) { // 排除非必填项 - if (key === 'apiImage') { + if (key === 'nodeSelector' || key === 'apiImage') { continue; } if (info[key] != '0' && !info[key]) { @@ -407,6 +423,14 @@ export default { resultValidate.validate = false; return false; } + + if (resourcePoolType === 'K8S' && info.nodeSelector) { + let validate = this.isJsonString(info.nodeSelector); + if (!validate) { + resultValidate.validate = false; + resultValidate.msg = this.$t('test_resource_pool.node_selector_invalid'); + } + } }); return resultValidate; }, @@ -435,7 +459,6 @@ export default { configuration.monitorPort = configuration.monitorPort || '9100'; configuration.deployType = configuration.deployType || 'DaemonSet'; configuration.deployName = configuration.deployName || 'ms-node-controller'; - delete configuration.nodeSelector; resources.push(configuration); }); } @@ -599,6 +622,16 @@ export default { let i = response.data.lastIndexOf('-'); this.apiImageTag = response.data.substring(0, i); }); + }, + isJsonString(str) { + try { + if (typeof JSON.parse(str) == "object") { + return true; + } + } catch (e) { + return false; + } + return false; } } }; diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 8ff3ecc5d1..82e4b6323f 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -2458,6 +2458,7 @@ export default { status_change_failed: 'Failed to change the status, resource pool is invalid!', check_in: 'Check in', node_selector_invalid: 'nodeSelector must be JSON', + node_selector_tip: 'Configure the nodeSelector of the load test Pod', pod_thread_limit: 'Maximum number of threads per POD', usage: 'Usage', backend_listener: 'Backend Listener', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index c8bfcccfb8..eb33611091 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -2462,6 +2462,7 @@ export default { status_change_failed: '状态修改失败, 校验不通过!', check_in: '校验中', node_selector_invalid: 'nodeSelector 必须是有效的JSON', + node_selector_tip: '配置性能测试Pod的 nodeSelector', pod_thread_limit: '单POD最大线程数', usage: '用途', backend_listener: '后置监听器', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index fc099791c9..bcde6ae26d 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -2461,6 +2461,7 @@ export default { status_change_failed: '狀態修改失敗, 校驗不通過!', check_in: '校驗中', node_selector_invalid: 'nodeSelector 必須是有效的JSON', + node_selector_tip: '配置性能測試Pod的 nodeSelector', pod_thread_limit: '單POD最大線程數', usage: '用途', backend_listener: '後置監聽器',