Skip to content

Commit f6d756f

Browse files
authored
feat(console): when cluster is containerd, disabled open logagent (#1549)
1 parent be0e737 commit f6d756f

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

web/console/src/modules/cluster/components/resource/clusterInfomation/ClusterDetailBasicInfoPanel.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ import { Clip } from '../../../../common/components';
2828
import { DialogNameEnum } from '../../../models';
2929
import { RootProps } from '../../ClusterApp';
3030
import { ClusterStatus } from '../../clusterManage/ClusterTablePanel';
31+
import { ContainerRuntimeEnum } from '@src/modules/cluster/constants/Config';
3132

3233
export class ClusterDetailBasicInfoPanel extends React.Component<RootProps, {}> {
3334
render() {
34-
let { cluster } = this.props;
35+
const { cluster } = this.props;
3536

3637
return (
3738
<FormPanel title={t('基本信息')}>
@@ -44,20 +45,20 @@ export class ClusterDetailBasicInfoPanel extends React.Component<RootProps, {}>
4445
);
4546
}
4647
_renderNodeMax() {
47-
let { cluster } = this.props;
48-
let clusterInfo: Cluster = cluster.selection;
48+
const { cluster } = this.props;
49+
const clusterInfo: Cluster = cluster.selection;
4950
if (clusterInfo && clusterInfo.spec.clusterCIDR) {
50-
let b = clusterInfo.spec.clusterCIDR.split('/')[1];
51-
let { maxNodePodNum, maxClusterServiceNum } = clusterInfo.spec.properties;
51+
const b = clusterInfo.spec.clusterCIDR.split('/')[1];
52+
const { maxNodePodNum, maxClusterServiceNum } = clusterInfo.spec.properties;
5253
return Math.pow(2, 32 - parseInt(b)) / maxNodePodNum - Math.ceil(maxClusterServiceNum / maxNodePodNum);
5354
} else {
5455
return '';
5556
}
5657
}
5758
/** 处理开关日志采集组件的的操作 */
5859
private _handleSwitch(cluster: Cluster) {
59-
let { actions, route } = this.props;
60-
let enableLogAgent = !cluster.spec.logAgentName;
60+
const { actions, route } = this.props;
61+
const enableLogAgent = !cluster.spec.logAgentName;
6162
if (enableLogAgent) {
6263
actions.cluster.enableLogAgent(cluster);
6364
} else {
@@ -70,9 +71,9 @@ export class ClusterDetailBasicInfoPanel extends React.Component<RootProps, {}>
7071
}
7172
/** 展示集群的基本信息 */
7273
private _renderClusterInfo() {
73-
let { actions, cluster } = this.props;
74-
let clusterInfo: Cluster = cluster.selection;
75-
let nodeMax = this._renderNodeMax();
74+
const { actions, cluster } = this.props;
75+
const clusterInfo: Cluster = cluster.selection;
76+
const nodeMax = this._renderNodeMax();
7677
return cluster.selection ? (
7778
<React.Fragment>
7879
<FormPanel.Item label={t('集群名称')} text>
@@ -89,6 +90,9 @@ export class ClusterDetailBasicInfoPanel extends React.Component<RootProps, {}>
8990
<FormPanel.Item label={t('Kubernetes版本')} text>
9091
{clusterInfo.status.version}
9192
</FormPanel.Item>
93+
<FormPanel.Item label={t('运行时组件')} text>
94+
{clusterInfo?.spec?.features?.enableContainerRuntime ?? ContainerRuntimeEnum.DOCKER}
95+
</FormPanel.Item>
9296
{clusterInfo.spec.networkDevice && (
9397
<FormPanel.Item label={t('网卡名称')} text>
9498
{clusterInfo.spec.networkDevice}

web/console/src/modules/cluster/components/resource/clusterInfomation/ClusterPlugInfoPanel.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,24 @@
1515
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
1616
* specific language governing permissions and limitations under the License.
1717
*/
18-
import React, { useEffect } from 'react';
18+
import React from 'react';
1919
import { FormPanel } from '@tencent/ff-component';
20-
import { Table, TableColumn, Button, Icon } from '@tea/component';
20+
import { Table, TableColumn, Button, Icon, Bubble } from '@tea/component';
2121
import { RootProps } from '../../ClusterApp';
2222
import { FetchState } from '@tencent/ff-redux';
2323
import { router } from '../../../router';
24+
import { ContainerRuntimeEnum } from '@src/modules/cluster/constants/Config';
2425

2526
enum PlugType {
2627
Promethus,
2728
LogAgent
2829
}
2930

30-
export const ClusterPlugInfoPanel: React.FC<RootProps> = ({ cluster, actions, clusterVersion, route }) => {
31-
const targetCluster = cluster.selection;
32-
const { promethus = null, logAgent = null } = targetCluster ? cluster.selection.spec : {};
33-
const clusterId = targetCluster ? targetCluster.metadata.name : '';
31+
export const ClusterPlugInfoPanel: React.FC<RootProps> = ({ cluster, actions, route }) => {
32+
const { promethus = null, logAgent = null } = cluster?.selection?.spec ?? {};
33+
const clusterId = cluster?.selection?.metadata?.name ?? '';
34+
35+
const isContainerd = cluster?.selection?.spec?.features?.enableContainerRuntime === ContainerRuntimeEnum.CONTAINERD;
3436

3537
const open = (type: PlugType) => () => {
3638
switch (type) {
@@ -66,16 +68,20 @@ export const ClusterPlugInfoPanel: React.FC<RootProps> = ({ cluster, actions, cl
6668
key: 'action',
6769
header: '操作',
6870
render({ action, type }) {
71+
const disabled = type === PlugType.LogAgent && isContainerd;
72+
6973
return action ? (
7074
<>
7175
<Button type="link" onClick={close(type)}>
7276
关闭
7377
</Button>
7478
</>
7579
) : (
76-
<Button type="link" onClick={open(type)}>
77-
开启
78-
</Button>
80+
<Bubble content={disabled ? '运行时为containerd的集群不支持开启日志采集' : ''}>
81+
<Button type="link" disabled={disabled} onClick={open(type)}>
82+
开启
83+
</Button>
84+
</Bubble>
7985
);
8086
}
8187
}
@@ -104,7 +110,12 @@ export const ClusterPlugInfoPanel: React.FC<RootProps> = ({ cluster, actions, cl
104110
{cluster.list.fetched !== true || cluster.list.fetchState === FetchState.Fetching ? (
105111
<Icon type="loading" />
106112
) : (
107-
<Table columns={columns} records={records} recordKey="des" />
113+
<Table
114+
columns={columns}
115+
records={records}
116+
recordKey="des"
117+
rowDisabled={({ type }) => type === PlugType.LogAgent && isContainerd}
118+
/>
108119
)}
109120
</FormPanel>
110121
);

web/console/src/modules/common/models/Cluster.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
1616
* specific language governing permissions and limitations under the License.
1717
*/
18+
import { ContainerRuntimeEnum } from '@src/modules/cluster/constants/Config';
1819
import { Identifiable } from '@tencent/ff-redux';
1920
import { Resource } from './Resource';
2021

@@ -56,6 +57,7 @@ interface ClusterSpec {
5657
features?: {
5758
ipvs: boolean;
5859
public: boolean;
60+
enableContainerRuntime?: ContainerRuntimeEnum;
5961
};
6062

6163
/** 集群类型 */

0 commit comments

Comments
 (0)