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

ds033 bugfix in cluster #694

Merged
merged 9 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
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
6 changes: 5 additions & 1 deletion ui/src/i18n/strings/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1244,5 +1244,9 @@
"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": "Delete protection modified successfully",
TianWuwt marked this conversation as resolved.
Show resolved Hide resolved
"src.pages.Tenant.Detail.Overview.EE772326": "Delete 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 !== 'running' || deletionProtection)
TianWuwt marked this conversation as resolved.
Show resolved Hide resolved
}
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([]);
TianWuwt marked this conversation as resolved.
Show resolved Hide resolved
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
Loading