Skip to content

Commit

Permalink
feat(frontend): 新增redis迁移单据 #7784
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves authored and jinquantianxia committed Nov 29, 2024
1 parent 969541c commit eb3d5b7
Show file tree
Hide file tree
Showing 42 changed files with 3,753 additions and 18 deletions.
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/common/const/ticketTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export enum TicketTypes {
REDIS_INSTANCE_CLOSE = 'REDIS_INSTANCE_CLOSE', // redis 主从集群禁用
REDIS_INSTANCE_DESTROY = 'REDIS_INSTANCE_DESTROY', // redis 主从集群删除
REDIS_CLUSTER_LOAD_MODULES = 'REDIS_CLUSTER_LOAD_MODULES', // redis 安装Module
REDIS_CLUSTER_INS_MIGRATE = 'REDIS_CLUSTER_INS_MIGRATE',
REDIS_SINGLE_INS_MIGRATE = 'REDIS_SINGLE_INS_MIGRATE',
}
export enum TicketTypes {
TENDBCLUSTER_APPLY = 'TENDBCLUSTER_APPLY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<template>
<div
v-bk-tooltips="{
disabled: !disabled,
disabled: !disabled || !disabledTooltips,
content: disabledTooltips,
}"
class="card-checkbox"
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/components/instance-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
spec_id?: number;
role: string;
shard?: string;
version?: string;
}

export type InstanceSelectorValues<T> = Record<string, T[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
cluster_type: '',
master_domain: data.related_clusters[0].immute_domain,
bk_cloud_name: data.bk_cloud_name,
related_clusters: data.related_clusters || [],
related_instances: (data.related_instances || []).map(instanceItem => ({
instance: instanceItem.instance,
status: instanceItem.status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
master_domain: data.master_domain,
spec_config: data.spec_config
});

const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function useTopoData<T extends Record<string, any>>(filterClusterId: Comp
.getTopoList(params)
.then((data) => {
const countFn = currentInstance.proxy?.countFunc;

const formatData = data.map((item: T) => {
let count = item.instance_count;
if (role === 'slave') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
type IValue,
type PanelListType,
} from '../../../Index.vue';
import RenderInstance from '../../common/render-instance/Index.vue';
import SerachBar from '../../common/SearchBar.vue';

import { useTableData } from './useTableData';
Expand Down Expand Up @@ -91,12 +92,17 @@
cluster_id: data.related_clusters[0].id,
port: 0,
instance_address: '',
cluster_type: '',
cluster_type: data.cluster_type,
master_domain: data.related_clusters[0].immute_domain,
bk_cloud_name: data.bk_cloud_name,
related_clusters: data.related_clusters || [],
related_instances: (data.related_instances || []).map(instanceItem => ({
instance: instanceItem.instance,
status: instanceItem.status
status: instanceItem.status,
bk_cloud_id: instanceItem.bk_cloud_id,
bk_host_id: instanceItem.bk_host_id,
ip: instanceItem.ip,
port: instanceItem.port,
})),
spec_config: data.spec_config,
db_module_id: data.db_module_id,
Expand Down Expand Up @@ -212,6 +218,13 @@
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
label: t('关联实例'),
field: 'related_instances',
showOverflowTooltip: true,
width: 200,
render: ({ data }: DataRow) => <RenderInstance data={data.related_instances || []}></RenderInstance>,
},
{
minWidth: 100,
label: t('云区域'),
Expand Down Expand Up @@ -276,7 +289,7 @@
field: item.field,
disabled: firstColumnFieldId.value === item.field,
})),
checked: [firstColumnFieldId.value, 'bk_cloud_id', 'role', 'status', 'cloud_area', 'alive', 'host_name', 'os_name'],
checked: [firstColumnFieldId.value, 'related_instances', 'bk_cloud_id', 'role', 'status', 'cloud_area', 'alive', 'host_name', 'os_name'],
}))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
master_domain: data.master_domain,
role: data.role
role: data.role,
spec_config: data.spec_config,
related_clusters: data.related_clusters,
version: data?.version || '',
});

const { t } = useI18n();
Expand Down Expand Up @@ -224,6 +227,7 @@
field: 'instance_role',
showOverflowTooltip: true,
filter: props.roleFilterList,
render: ({ data }: DataRow) => data.instance_role || '--'
},
{
label: t('实例状态'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function useTableData<T>(
}
if (clusterId?.value && clusterId.value !== currentBizId) {
Object.assign(params, {
cluster_ids: clusterId.value,
cluster_id: clusterId.value,
});
}
return params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<template>
<BkPopover
height="0"
placement="bottom"
:placement="placement"
:popover-delay="[100, 200]"
theme="light"
width="514">
Expand Down Expand Up @@ -86,6 +86,8 @@
</BkPopover>
</template>
<script setup lang="ts">
import { Popover } from 'bkui-vue';
import type { ComponentProps } from 'vue-component-type-helpers';
import { useI18n } from 'vue-i18n';

export interface SpecInfo {
Expand Down Expand Up @@ -114,6 +116,7 @@
interface Props {
data?: SpecInfo;
hideQps?: boolean;
placement?: ComponentProps<typeof Popover>['placement'];
}

withDefaults(defineProps<Props>(), {
Expand Down Expand Up @@ -142,6 +145,7 @@
],
}),
hideQps: false,
placement: 'bottom',
});

const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {
generateRedisDataStructureCloneData,
generateRedisInstallModule,
generateRedisMasterSlaveSwitchCloneData,
generateRedisMigrateClusterCloneData,
generateRedisMigrateSingleCloneData,
generateRedisOperationCloneData,
generateRedisProxyScaleDownCloneData,
generateRedisProxyScaleUpCloneData,
Expand Down Expand Up @@ -93,6 +95,8 @@ export const generateCloneDataHandlerMap = {
[TicketTypes.REDIS_BACKUP]: generateRedisOperationCloneData, // Redis 集群备份
[TicketTypes.REDIS_PURGE]: generateRedisOperationCloneData,
[TicketTypes.REDIS_CLUSTER_LOAD_MODULES]: generateRedisInstallModule, // Redis 安装Module
[TicketTypes.REDIS_CLUSTER_INS_MIGRATE]: generateRedisMigrateClusterCloneData, // Redis 集群迁移
[TicketTypes.REDIS_SINGLE_INS_MIGRATE]: generateRedisMigrateSingleCloneData, // Redis 主从迁移
[TicketTypes.MYSQL_AUTHORIZE_RULES]: generateMysqlAuthorizeRuleCloneData, // Mysql 集群授权
[TicketTypes.MYSQL_IMPORT_SQLFILE]: generateMysqlImportSqlFileCloneData, // Mysql SQL变更执行
[TicketTypes.MYSQL_CHECKSUM]: generateMysqlChecksumCloneData, // Mysql 数据校验
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export * from './dataCopyCheckRepair';
export * from './dataStructure';
export * from './installModule';
export * from './masterSlaveSwitch';
export * from './migrateCluster';
export * from './migrateSingle';
export * from './operation';
export * from './proxyScaleDown';
export * from './proxyScaleUp';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
*
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
* the specific language governing permissions and limitations under the License.
*/
import type { RedisClusterMigrate } from '@services/model/ticket/details/redis';
import TicketModel from '@services/model/ticket/ticket';

import { random } from '@utils';

// Redis 集群迁移
export async function generateRedisMigrateClusterCloneData(ticketData: TicketModel<RedisClusterMigrate>) {
const { infos, clusters, specs } = ticketData.details;
const tableDataList = infos.map((infoItem) => {
const clusterItem = clusters[infoItem.cluster_id];
const specItem = specs[infoItem.resource_spec.backend_group.spec_id];
return {
rowKey: random(),
isLoading: false,
spanData: {
isStart: false,
isGeneral: true,
rowSpan: 1,
},
clusterData: {
instance: infoItem.display_info.instance,
domain: clusterItem.immute_domain,
clusterId: clusterItem.id,
clusterType: clusterItem.cluster_type,
specId: specItem.id,
specName: specItem.name,
},
master: infoItem.old_nodes.master[0],
slave: infoItem.old_nodes.slave[0],
};
});

return {
tableDataList,
remark: ticketData.remark,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
*
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
* the specific language governing permissions and limitations under the License.
*/
import type { RedisSingleMigrate } from '@services/model/ticket/details/redis';
import TicketModel from '@services/model/ticket/ticket';

import { random } from '@utils';

// Redis 主从迁移
export async function generateRedisMigrateSingleCloneData(ticketData: TicketModel<RedisSingleMigrate>) {
const { infos, clusters } = ticketData.details;
const isDomain = infos[0].display_info.migrate_type === 'domain';
const mapKey = isDomain ? 'domain' : 'ip';

const rowMap = infos.reduce<Record<string, RedisSingleMigrate['infos']>>((prevMap, infoItem) => {
if (prevMap[infoItem.display_info[mapKey]]) {
return Object.assign({}, prevMap, {
[infoItem.display_info[mapKey]]: prevMap[infoItem.display_info[mapKey]].concat(infoItem),
});
}
return Object.assign({}, prevMap, {
[infoItem.display_info[mapKey]]: [infoItem],
});
}, {});
const tableDataList = Object.values(rowMap).map((infoList) => {
const rowItem = infoList[0];
const clusterItem = clusters[rowItem.cluster_id];
const relatedInstanceList = infoList.map((infoItem) => {
const masterItem = infoItem.old_nodes.master[0];
return {
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
bk_cloud_id: masterItem.bk_cloud_id,
bk_host_id: masterItem.bk_host_id,
ip: masterItem.ip,
port: masterItem.port,
instance: `${masterItem.ip}:${masterItem.port}`,
};
});

const clusterData = isDomain
? {
domain: rowItem.display_info.domain,
cloudId: clusterItem.bk_cloud_id,
clusterType: clusterItem.cluster_type,
clusterId: rowItem.cluster_id,
relatedInstance: relatedInstanceList,
}
: {
ip: rowItem.display_info.ip,
cloudId: clusterItem.bk_cloud_id,
clusterType: clusterItem.cluster_type,
relatedInstance: relatedInstanceList,
};
return {
rowKey: random(),
isLoading: false,
clusterData,
targetSpecId: rowItem.resource_spec.backend_group.spec_id,
targetVersion: rowItem.db_version,
};
});
return {
tableDataList,
remark: ticketData.remark,
isDomain,
};
}
20 changes: 20 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3682,5 +3682,25 @@
"请选择本地 SQL 文件": "请选择本地 SQL 文件",
"实际内存分配比率": "实际内存分配比率",
"忽略错误": "忽略错误",
"迁移提交成功": "迁移提交成功",
"集群架构:将集群的部分实例迁移到新机器,迁移保持规格、版本不变;主从架构:主从实例成对迁移到新机器上,可选择部分实例迁移,也可整机所有实例一起迁移。": "集群架构:将集群的部分实例迁移到新机器,迁移保持规格、版本不变;主从架构:主从实例成对迁移到新机器上,可选择部分实例迁移,也可整机所有实例一起迁移。",
"迁移": "迁移",
"实例迁移": "实例迁移",
"如 TendisCache 等,迁移过程保持规格、版本不变": "如 TendisCache 等,迁移过程保持规格、版本不变",
"支持部分或整机所有实例成对迁移至新主机,版本规格可变": "支持部分或整机所有实例成对迁移至新主机,版本规格可变",
"主从架构": "主从架构",
"只迁移目标实例": "只迁移目标实例",
"主机关联的所有实例一并迁移": "主机关联的所有实例一并迁移",
"整机迁移": "整机迁移",
"目标 Master 实例": "目标 Master 实例",
"实例选择": "实例选择",
"目标 Master 主机": "目标 Master 主机",
"关联的实例": "关联的实例",
"关联的主从实例": "关联的主从实例",
"目标实例输入格式有误": "目标实例输入格式有误",
"目标实例重复": "目标实例重复",
"Master 实例": "Master 实例",
"请先选择主机": "请先选择主机",
"集群或实例状态异常,不可选择": "集群或实例状态异常,不可选择",
"这行勿动!新增翻译请在上一行添加!": ""
}
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/services/model/redis/redis-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class RedisInstance {
related_clusters: InstanceRelatedCluster[];
role: string;
slave_domain: string;
spce_config: InstanceListSpecConfig;
spec_config: InstanceListSpecConfig;
status: ClusterInstStatus;
version: string;

Expand Down Expand Up @@ -71,7 +71,7 @@ export default class RedisInstance {
this.related_clusters = payload.related_clusters || [];
this.role = payload.role || '';
this.slave_domain = payload.slave_domain || '';
this.spce_config = payload.spce_config || {};
this.spec_config = payload.spec_config || {};
this.status = payload.status || '';
this.version = payload.version || '';
}
Expand Down
Loading

0 comments on commit eb3d5b7

Please sign in to comment.