Skip to content

Commit

Permalink
ds033 bugfix in cluster (#694)
Browse files Browse the repository at this point in the history
* fix storageClass in cluster new

* fix deletionProtection in TopoData

* fix topo NodeSelectorFrom value in cluster new

* fix cpu progress and memory progress in NodesTable

* update i18n and mds

* fix dropmenu disable and Parameters search in clusterDetail

* fix delete cluste disable and deletedParameters in  Parameter table

* fix CR

* fix CR
  • Loading branch information
TianWuwt authored Dec 26, 2024
1 parent 45797ed commit 5a48ee4
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 41 deletions.
7 changes: 1 addition & 6 deletions ui/src/components/SelectWithTooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default function SelectWithTooltip({
selectList,
form,
name,
type,
TooltipItemContent,
}: SelectWithTooltipProps) {
const filterOption = (
Expand Down Expand Up @@ -61,11 +60,7 @@ export default function SelectWithTooltip({
filterOption={filterOption}
options={formatData(selectList)}
onChange={selectChange}
value={
type === 'observer' && formatData(selectList)?.length !== 1
? ''
: form.getFieldValue(name)
}
value={form.getFieldValue(name)}
// dropdownRender={DropDownComponent}
/>
);
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/TopoComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ReactNode, config } from './G6register';
import {
clusterOperate,
clusterOperateOfTenant,
getClusterOperates,
getServerOperateOfCluster,
getZoneOperateOfCluster,
getZoneOperateOfTenant,
Expand Down
1 change: 1 addition & 0 deletions ui/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const TOPO_INFO_CONFIG = [
'image',
'mode',
'rootPasswordSecret',
'deletionProtection',
];

// use for tenant name or zone name
Expand Down
14 changes: 9 additions & 5 deletions ui/src/i18n/strings/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
"src.constants.Warning": "Warning",
"src.pages.Tenant.New.6071B46A": "Optimization Scenarios",
"src.pages.Tenant.New.7D0448C6": "Please select an optimization scenario",
"src.pages.Tenant.New.3979BAB6": "Delete protection",
"src.pages.Tenant.New.3979BAB6": "Deletion protection",
"src.pages.Tenant.Detail.Overview.2D1BC77D": "Unlimited",
"src.pages.Tenant.Detail.NewBackup.F6D664A0": "Please enter Host",
"src.pages.Tenant.Detail.NewBackup.7A899F0F": "Please enter AppID",
Expand All @@ -1175,7 +1175,7 @@
"src.pages.Cluster.New.94B6798C": "PVC independent life cycle",
"src.pages.Cluster.New.04047AB8": "Optimization Scenarios",
"src.pages.Cluster.New.8126F0B5": "Please select an optimization scenario",
"src.pages.Cluster.New.FCB7C4F3": "Delete protection",
"src.pages.Cluster.New.FCB7C4F3": "Deletion protection",
"src.pages.Cluster.New.1E85AB3D": "Mount NFS resources",
"src.pages.Cluster.Detail.Overview.C47B9DA4": "Remove NFS resources",
"src.pages.Cluster.Detail.Overview.6B97ABB6": "Mount NFS backup volumes",
Expand Down Expand Up @@ -1236,13 +1236,17 @@
"src.pages.Cluster.Detail.Overview.B7E9F065": "Please enter a path",
"src.pages.Cluster.Detail.Overview.D0356ACB": "Please enter",
"src.pages.Cluster.Detail.Overview.0798E33D": "Note that mounting the backup volume will roll-restart all nodes",
"src.pages.Cluster.Detail.Overview.02AE8EA0": "Delete protection modified successfully",
"src.pages.Cluster.Detail.Overview.8DB38279": "Delete protection",
"src.pages.Cluster.Detail.Overview.02AE8EA0": "Deletion protection modified successfully",
"src.pages.Cluster.Detail.Overview.8DB38279": "Deletion protection",
"src.components.TopoComponent.AD3D247F": "Server deleted successfully",
"src.components.TopoComponent.86ECC17E": "Restarting the Server successfully",
"src.components.TopoComponent.FAB70713": "Are you sure you want to delete this server?",
"src.components.TopoComponent.96A4C193": "Are you sure you want to restart the server?",
"src.components.TopoComponent.601BE33A": "Unlimited",
"src.components.TopoComponent.0E4AAB80": "Unlimited",
"src.components.TopoComponent.2494A473": "Restart the server"
"src.components.TopoComponent.2494A473": "Restart the server",
"src.pages.Tenant.Detail.Overview.892E62C7": "Deletion protection modified successfully",
"src.pages.Tenant.Detail.Overview.EE772326": "Deletion protection",
"src.pages.Overview.E15A1FED": "metrics-server has not been installed in the K8s cluster, and the usage of node resources cannot be obtained.",
"src.pages.Cluster.Detail.Overview.FF85D01F": "Unmanaged Successfully"
}
6 changes: 5 additions & 1 deletion ui/src/i18n/strings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1266,5 +1266,9 @@
"src.components.TopoComponent.96A4C193": "你确定重启该 server 吗?",
"src.components.TopoComponent.601BE33A": "无限制",
"src.components.TopoComponent.0E4AAB80": "无限制",
"src.components.TopoComponent.2494A473": "重启server"
"src.components.TopoComponent.2494A473": "重启server",
"src.pages.Tenant.Detail.Overview.892E62C7": "修改删除保护已成功",
"src.pages.Tenant.Detail.Overview.EE772326": "删除保护",
"src.pages.Overview.E15A1FED": "K8s 集群中尚未安装 metrics-server,无法获取节点资源用量",
"src.pages.Cluster.Detail.Overview.FF85D01F": "解除托管已成功"
}
68 changes: 51 additions & 17 deletions ui/src/pages/Cluster/Detail/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ const ClusterOverview: React.FC = () => {
},
});

const { runAsync: patchOBCluster, loading: patchOBClusterloading } =
useRequest(obcluster.patchOBCluster, {
manual: true,
onSuccess: (res) => {
if (res.successful) {
message.success(
intl.formatMessage({
id: 'src.pages.Cluster.Detail.Overview.FF85D01F',
defaultMessage: '解除托管已成功',
}),
);
refresh();
clusterDetailRefresh();
}
},
});

const handleDelete = async () => {
const res = await deleteClusterReportWrap({ ns: ns!, name: name! });
if (res.successful) {
Expand Down Expand Up @@ -156,8 +173,7 @@ const ClusterOverview: React.FC = () => {
<Button
onClick={handleAddZone}
disabled={
clusterDetail?.status === 'operating' ||
clusterDetail?.status === 'failed'
!isEmpty(clusterDetail) && clusterDetail?.status !== 'running'
}
type="text"
>
Expand All @@ -174,8 +190,7 @@ const ClusterOverview: React.FC = () => {
<Button
type="text"
disabled={
clusterDetail?.status === 'operating' ||
clusterDetail?.status === 'failed'
!isEmpty(clusterDetail) && clusterDetail?.status !== 'running'
}
onClick={handleUpgrade}
>
Expand All @@ -191,6 +206,10 @@ const ClusterOverview: React.FC = () => {
label: (
<Button
type="text"
disabled={
!isEmpty(clusterDetail) &&
(clusterDetail?.status === 'deleting' || deletionProtection)
}
onClick={() =>
showDeleteConfirm({
onOk: handleDelete,
Expand Down Expand Up @@ -264,7 +283,8 @@ const ClusterOverview: React.FC = () => {
};
};

const { parameters, storage, resource } = clusterDetail?.info || {};
const { parameters, storage, resource, deletionProtection } =
clusterDetail?.info || {};

const resourceinit = [
{
Expand Down Expand Up @@ -350,6 +370,7 @@ const ClusterOverview: React.FC = () => {
})}
</Tag>
),

value: true,
},
{
Expand All @@ -361,6 +382,7 @@ const ClusterOverview: React.FC = () => {
})}
</Tag>
),

value: false,
},
];
Expand Down Expand Up @@ -440,12 +462,10 @@ const ClusterOverview: React.FC = () => {
})}
/>
),

dataIndex: 'accordance',
width: 100,
render: (text: boolean, record: any) => {
if (!record?.controlParameter) {
return '-';
}
render: (text: boolean) => {
const tagColor = text ? 'green' : 'gold';
const tagContent = text
? intl.formatMessage({
Expand Down Expand Up @@ -483,7 +503,15 @@ const ClusterOverview: React.FC = () => {
})}
</Button>
{text && (
<Button type="link" onClick={() => {}}>
<Button
type="link"
loading={patchOBClusterloading}
onClick={() => {
patchOBCluster(ns, name, {
deletedParameters: [record.name],
});
}}
>
{intl.formatMessage({
id: 'src.pages.Cluster.Detail.Overview.5FACF7C0',
defaultMessage: '解除托管',
Expand Down Expand Up @@ -641,30 +669,32 @@ const ClusterOverview: React.FC = () => {
const newParametersData = getNewData(
listOBClusterParameters?.data,
);

if (name) {
if (name !== undefined) {
setParametersData(
newParametersData?.filter((item) =>
item.name?.includes(name),
),
);
}
if (controlParameter) {
if (controlParameter !== undefined) {
setParametersData(
newParametersData?.filter(
(item) =>
item.controlParameter === controlParameter,
),
);
}
if (accordance) {
if (accordance !== undefined) {
setParametersData(
newParametersData?.filter(
(item) => item.accordance === accordance,
),
);
}
if (!!name && !!controlParameter) {
if (
name !== undefined &&
controlParameter !== undefined
) {
setParametersData(
newParametersData?.filter(
(item) =>
Expand All @@ -673,7 +703,7 @@ const ClusterOverview: React.FC = () => {
),
);
}
if (!!name && !!accordance) {
if (name !== undefined && accordance !== undefined) {
setParametersData(
newParametersData?.filter(
(item) =>
Expand All @@ -682,7 +712,11 @@ const ClusterOverview: React.FC = () => {
),
);
}
if (!!name && !!controlParameter && !!accordance) {
if (
name !== undefined &&
controlParameter !== undefined &&
accordance !== undefined
) {
setParametersData(
newParametersData?.filter(
(item) =>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/pages/Cluster/New/Topo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function Topo({ form }) {
const [showTopology, setShowTopology] = useState<boolean>(false);
const [formsubIndex, setFromSubIndex] = useState({});

const [keyList, setKeyList] = useState<ListType[]>([]);
const [valList, setValList] = useState<ListType[]>([]);
const [keyList, setKeyList] = useState([]);
const [valList, setValList] = useState([]);

const access = useAccess();

Expand Down Expand Up @@ -103,7 +103,7 @@ export default function Topo({ form }) {
const promise = getNodeLabelsReq();
promise.then((data) => {
setKeyList(data.key);
setValList(data.value);
setValList(data.value?.filter((item) => item.label !== ''));
});
}
}, []);
Expand Down
25 changes: 18 additions & 7 deletions ui/src/pages/Overview/NodesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getNodeInfoReq } from '@/services';
import { intl } from '@/utils/intl';
import { findByValue } from '@oceanbase/util';
import { useRequest } from 'ahooks';
import { Card, Col, Progress, Table, Tag } from 'antd';
import { Card, Col, Progress, Table, Tag, Tooltip } from 'antd';
import type { ColumnsType } from 'antd/es/table';

interface DataType {
Expand All @@ -23,6 +23,21 @@ interface DataType {
memory: string;
}

const progressContent = (value: number, resource: number) => {
return resource === 0 ? (
<Tooltip
title={intl.formatMessage({
id: 'src.pages.Overview.E15A1FED',
defaultMessage:
'K8s 集群中尚未安装 metrics-server,无法获取节点资源用量',
})}
>
- / -
</Tooltip>
) : (
<Progress status="normal" strokeLinecap="butt" percent={value} />
);
};
const columns: ColumnsType<DataType> = [
{
title: intl.formatMessage({
Expand Down Expand Up @@ -132,9 +147,7 @@ const columns: ColumnsType<DataType> = [
}),
dataIndex: 'cpu',
key: 'cpu',
render: (value) => (
<Progress status="normal" strokeLinecap="butt" percent={value} />
),
render: (value, record) => progressContent(value, record.cpuTotal),
},
{
title: intl.formatMessage({
Expand All @@ -143,9 +156,7 @@ const columns: ColumnsType<DataType> = [
}),
dataIndex: 'memory',
key: 'memory',
render: (value) => (
<Progress status="normal" strokeLinecap="butt" percent={value} />
),
render: (value, record) => progressContent(value, record.memoryTotal),
},
];

Expand Down
14 changes: 12 additions & 2 deletions ui/src/pages/Tenant/Detail/Overview/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export default function BasicInfo({
manual: true,
onSuccess: (res) => {
if (res.successful) {
message.success('修改删除保护已成功');
message.success(
intl.formatMessage({
id: 'src.pages.Tenant.Detail.Overview.892E62C7',
defaultMessage: '修改删除保护已成功',
}),
);
}
},
},
Expand Down Expand Up @@ -119,7 +124,12 @@ export default function BasicInfo({
);
})}
{deletionProtection && (
<Descriptions.Item label={'删除保护'}>
<Descriptions.Item
label={intl.formatMessage({
id: 'src.pages.Tenant.Detail.Overview.EE772326',
defaultMessage: '删除保护',
})}
>
<Checkbox
// loading 态禁止操作,防止重复操作
disabled={patchTenantLoading}
Expand Down

0 comments on commit 5a48ee4

Please sign in to comment.