From 974427c3d8a1652e4f61387bfc121bcae2ea9f32 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Mon, 13 Feb 2023 18:00:34 +0800 Subject: [PATCH] fix: fix the resize of magnum cluster 1. specify the request header `OpenStack-API-Version: container-infra latest` to fix response code 406 2. fix the nodes_to_remove according to the api ref document Change-Id: Ibf5760e88d7772facc4960f0f1f947444dfc227f --- src/locales/en.json | 2 ++ src/locales/zh.json | 2 ++ .../containers/Clusters/actions/Resize.jsx | 28 +++++++++---------- src/stores/magnum/clusters.js | 4 ++- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index f65b7e55..9c79e9f1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1732,6 +1732,8 @@ "Please enter right format key value!": "Please enter right format key value!", "Please enter right format memory page value!": "Please enter right format memory page value!", "Please enter right format trait!": "Please enter right format trait!", + "Please enter the correct id": "Please enter the correct id", + "Please enter the server id to be reduced, and separate different id with \",\"": "Please enter the server id to be reduced, and separate different id with \",\"", "Please fill in the peer network segment and subnet mask of CIDR format, the written subnets should be under the same router, one per line.": "Please fill in the peer network segment and subnet mask of CIDR format, the written subnets should be under the same router, one per line.", "Please input": "Please input", "Please input ICMP code(0-255)": "Please input ICMP code(0-255)", diff --git a/src/locales/zh.json b/src/locales/zh.json index 13c2539a..afc3a391 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -1732,6 +1732,8 @@ "Please enter right format key value!": "请输入正确格式的键值", "Please enter right format memory page value!": "请输入正确格式的内存页值", "Please enter right format trait!": "请输入正确格式的特性!", + "Please enter the correct id": "请输入正确的ID", + "Please enter the server id to be reduced, and separate different id with \",\"": "请输入指定缩减的server ID,并且不同ID之间用 ',' 分隔", "Please fill in the peer network segment and subnet mask of CIDR format, the written subnets should be under the same router, one per line.": "请填写CIDR格式的对端网段,且填写的网段需在同一个路由下,每行一个。", "Please input": "请输入", "Please input ICMP code(0-255)": "请输入ICMP编码(0-255)", diff --git a/src/pages/container-infra/containers/Clusters/actions/Resize.jsx b/src/pages/container-infra/containers/Clusters/actions/Resize.jsx index 438b50e6..659b7129 100644 --- a/src/pages/container-infra/containers/Clusters/actions/Resize.jsx +++ b/src/pages/container-infra/containers/Clusters/actions/Resize.jsx @@ -116,14 +116,6 @@ export class Resize extends ModalAction { return ['changed_node_count']; } - get nodeAddressOptions() { - const { node_addresses = [] } = this.item; - return node_addresses.map((it) => ({ - label: it, - value: it, - })); - } - get formItems() { const { changed_node_count } = this.state; const { node_count = 0 } = this.item; @@ -162,9 +154,17 @@ export class Resize extends ModalAction { { name: 'nodes_to_remove', label: t('Nodes To Remove'), - type: 'select', - mode: 'multiple', - options: this.nodeAddressOptions, + type: 'textarea', + placeholder: t( + 'Please enter the server id to be reduced, and separate different id with ","' + ), + validator: (rule, value) => { + const pattern = /^[0-9a-zA-Z]+([0-9a-zA-Z,-][0-9a-zA-Z]+)*$/; + if (value && !pattern.test(value)) { + return Promise.reject(new Error(t('Please enter the correct id'))); + } + return Promise.resolve(); + }, display: changed_node_count < node_count, }, ]; @@ -177,11 +177,11 @@ export class Resize extends ModalAction { node_count: changed_node_count, nodes_to_remove: [], }; - if (nodes_to_remove && nodes_to_remove.length) { - body.nodes_to_remove = nodes_to_remove; + if (nodes_to_remove) { + body.nodes_to_remove = nodes_to_remove.split(','); } - this.store.resize({ id: this.item.id }, body); + return this.store.resize({ id: this.item.id }, body); }; } diff --git a/src/stores/magnum/clusters.js b/src/stores/magnum/clusters.js index d1d24b8b..a22f4dde 100644 --- a/src/stores/magnum/clusters.js +++ b/src/stores/magnum/clusters.js @@ -58,7 +58,9 @@ export class ClustersStore extends Base { @action async resize({ id }, newbody) { - return this.client.resize(id, newbody); + return this.client.resize(id, newbody, null, { + headers: { 'OpenStack-API-Version': 'container-infra latest' }, + }); } async upgrade({ id }, body) {