Skip to content

Commit

Permalink
feat(frontend): mysql版本升级支持一主多从 TencentBlueKing#7438
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves authored and hLinx committed Oct 28, 2024
1 parent 10de90d commit 94ba015
Show file tree
Hide file tree
Showing 17 changed files with 775 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function generateMysqlVersionLocalUpgradeCloneData(ticketData: Tick
[ClusterTypes.TENDBHA]: getTendbhaList,
};
const clusterListResult = await apiMap[clusterType as keyof typeof apiMap]({
id: infos.map((item) => item.cluster_ids[0]).join(','),
cluster_ids: infos.map((item) => item.cluster_ids[0]),
});
const clusterListMap = clusterListResult.results.reduce(
(obj, item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { random } from '@utils';
export async function generateMysqlVersionMigrateUpgradeCloneData(ticketData: TicketModel<MySQLMigrateUpgradeDetails>) {
const { clusters, infos, backup_source: backupSource, force } = ticketData.details;
const clusterListResult = await getTendbhaList({
id: infos.map((item) => item.cluster_ids[0]).join(','),
cluster_ids: infos.map((item) => item.cluster_ids[0]),
});
const clusterListMap = clusterListResult.results.reduce(
(obj, item) => {
Expand All @@ -46,12 +46,30 @@ export async function generateMysqlVersionMigrateUpgradeCloneData(ticketData: Ti
packageVersion: clusterListMap[clusterId].masters[0].version,
moduleName: item.display_info.current_module_name,
cloudId: clusters[clusterId].bk_cloud_id,
masterSlaveList: [
...clusterListMap[clusterId].masters,
...clusterListMap[clusterId].slaves.filter((item) => item.is_stand_by),
].map((item) => ({
bk_biz_id: item.bk_biz_id,
bk_host_id: item.bk_host_id,
ip: item.ip,
bk_cloud_id: item.bk_cloud_id,
})),
readonlySlaveList: clusterListMap[clusterId].slaves
.filter((item) => !item.is_stand_by)
.map((item) => ({
bk_biz_id: item.bk_biz_id,
bk_host_id: item.bk_host_id,
ip: item.ip,
bk_cloud_id: item.bk_cloud_id,
})),
},
targetVersion: item.display_info.target_version,
targetPackage: item.pkg_id,
targetModule: item.new_db_module_id,
masterHostData: item.new_master,
slaveHostData: item.new_slave,
readonlyHostData: (item.read_only_slaves || []).map((readonlySlaveItem) => readonlySlaveItem.new_slave),
};
});

Expand Down
51 changes: 50 additions & 1 deletion dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3496,5 +3496,54 @@
"特殊字符不允许包含空格": "特殊字符不允许包含空格",
"请输入除大小写字母、数字外的英文半角字符": "请输入除大小写字母、数字外的英文半角字符",
"请输入英文半角字符,重复字符将去重": "请输入英文半角字符,重复字符将去重",
"Follower节点规格": "Follower 节点规格",
"Observer节点规格": "Observer 节点规格",
"【Doris】集群管理": "【Doris】集群管理",
"申请Doris集群部署": "申请Doris集群部署",
"Doris版本": "Doris 版本",
"Follower节点": "Follower 节点",
"Observer节点": "Observer 节点",
"固定为n台": "固定为 {0} 台",
"查询端口": "查询端口",
"主机已被Follower节点使用": "主机已被 Follower 节点使用",
"主机已被Observer节点使用": "主机已被 Observer 节点使用",
"Follower节点IP": "Follower 节点 IP",
"Observer节点IP": "Observer 节点 IP",
"9010 和 9020 为服务内部占用端口": "9010 和 9020 为服务内部占用端口",
"与http端口互斥": "与 http 端口互斥",
"与查询端口互斥": "与查询端口互斥",
"至少添加一种节点IP": "至少添加一种节点 IP",
"name容量从n台扩容至n台": "{name} 容量从 {hostNumBefore} 台扩容至 {hostNumAfter} 台",
"name容量从n台缩容至n台": "{name} 容量从 {hostNumBefore} 台缩容至 {hostNumAfter} 台",
"至少缩容一种类型": "至少缩容一种类型",
"当前数量": "当前数量",
"确认禁用该集群?": "确认禁用该集群?",
"确认启用该集群?": "确认启用该集群?",
"启用后,将会恢复访问": "启用后,将会恢复访问",
"删除后将产生以下影响": "删除后将产生以下影响:",
"删除xxx集群": "删除 {0} 集群",
"删除xxx实例数据,停止相关进程": "删除 {xxx} 实例数据,停止相关进程",
"确认扩容集群?": "确认扩容集群?",
"若选择至少需要n台": "若选择至少需要 {0} 台",
"若选择至少需要n台,已选m台": "若选择至少需要 {0} 台,已选 {1} 台",
"扩容中": "扩容中",
"缩容中": "缩容中",
"替换中": "替换中",
"请保证冷/热节点至少存在一种": "请保证冷/热节点至少存在一种",
"Follower节点不支持缩容": "Follower节点不支持缩容",
"Follower类型节点若存在至少保留两台": "Follower类型节点若存在至少保留两台",
"冷/热 数据节点必选 1 种以上,每个角色至少需要 2 台": "冷/热 数据节点必选 1 种以上,每个角色至少需要 2 台",
"未完善": "未完善",
"扩容的节点 IP": "扩容的节点 IP",
"实例正在重启中,不能勾选": "实例正在重启中,不能勾选",
"较目标容量相差n台": ",较目标容量相差 {0} 台",
"较目标容量超出n台": ",较目标容量超出 {0} 台",
"Observer类型节点若存在至少保留两台": "Observer类型节点若存在至少保留两台",
"主从主机": "主从主机",
"只读主机": "只读主机",
"新主从主机": "新主从主机",
"新只读主机": "新只读主机",
"请输入n台IP_英文逗号或换行分隔": "请输入 {n} 台IP_英文逗号或换行分隔",
"请输入n台IP": "请输入 {n} 台IP",
"这行勿动!新增翻译请在上一行添加!": ""
}
}
5 changes: 5 additions & 0 deletions dbm-ui/frontend/src/services/model/ticket/details/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ export interface MySQLMigrateUpgradeDetails extends DetailBase {
pkg_id: string;
new_master: MysqlIpItem;
new_slave: MysqlIpItem;
read_only_slaves?: {
old_slave: MysqlIpItem;
new_slave: MysqlIpItem;
}[];
display_info: {
current_version: string;
target_version: string;
Expand All @@ -609,6 +613,7 @@ export interface MySQLMigrateUpgradeDetails extends DetailBase {
charset: string;
current_module_name: string;
target_module_name: string;
old_master_slave?: string[];
};
}[];
force: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
theme="info"
:title="
t(
'版本升级:接入层可直接原地升级,存储层需先创建相应版本的模块,连续版本可直接升级,跨版本需提供新机通过迁移完成升级;同机所有关联集群将一并升级',
'版本升级:主从接入层和单节点采用原地升级,存储层小版本升级采用原地升级(注意:暂不支持一主多从),大版本需提供新机迁移方式执行。同一主机所有关联集群将一并同步升级',
)
" />
<DbForm
Expand All @@ -29,9 +29,7 @@
:label="t('角色类型')"
property="roleType"
required>
<BkRadioGroup
v-model="formData.roleType"
@change="handleRoleTypeChange">
<BkRadioGroup v-model="formData.roleType">
<BkRadioButton
v-for="item in roleTypeList"
:key="item.value"
Expand Down Expand Up @@ -130,6 +128,7 @@
window.changeConfirm = true;

formData.roleType = 'haStorageLayer';
formData.updateType = 'remote';
nextTick(() => {
formData.updateType = 'remote';
});
Expand Down Expand Up @@ -169,15 +168,17 @@

const formData = reactive(initFormData());

const renderKey = computed(() => `${formData.roleType}-${formData.updateType}`);

const currentTable = computed(() => {
const { roleType, updateType } = formData;
if (roleType === 'haAccessLayer') {
const [currentUpdateType, currentRoleType] = renderKey.value.split('-');
if (currentUpdateType === 'haAccessLayer') {
return RenderAccessLayerTable;
}
if (roleType === 'singleStorageLayer') {
if (currentUpdateType === 'singleStorageLayer') {
return RenderSingleStorageTable;
}
if (updateType === 'local') {
if (currentRoleType === 'local') {
return RenderStorageLayerLocalTable;
}
return RenderStorageLayerRemoteTable;
Expand All @@ -190,21 +191,15 @@
},
);

watch(
() => formData.updateType,
() => {
tableList.value = [];
remark.value = '';
if (formData.updateType === '') {
formData.updateType = 'local';
}
},
);

const handleRoleTypeChange = () => {
remark.value = '';
watch(renderKey, () => {
tableList.value = [];
};
remark.value = '';
});

// const handleRoleTypeChange = () => {
// remark.value = '';
// tableList.value = [];
// };
</script>

<style lang="less">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<div class="force-action">
<BkCheckbox
v-model="modelValue"
v-bk-tooltips="t('如忽略,有连接的情况下也会执行强制升级')">
<span class="force-action-text">{{ t('忽略业务连接') }}</span>
</BkCheckbox>
</div>
</template>

<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const modelValue = defineModel<boolean>({
required: true,
});
const { t } = useI18n();
</script>

<style lang="less" scoped>
.force-action {
margin-top: 20px;
.force-action-text {
padding-bottom: 2px;
border-bottom: 1px dashed #979ba5;
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@
@remove="handleRemove(index)" />
</template>
</RenderTable>
<div class="force-action">
<BkCheckbox
v-model="isForce"
v-bk-tooltips="t('如忽略,有连接的情况下也会执行强制升级')">
<span class="force-action-text">{{ t('忽略业务连接') }}</span>
</BkCheckbox>
</div>
<ForceAction v-model="isForce" />
<TicketRemark v-model="localRemark" />
<ClusterSelector
v-model:is-show="isShowClusterSelector"
Expand Down Expand Up @@ -110,6 +104,8 @@
import BatchOperateIcon from '@views/db-manage/common/batch-operate-icon/Index.vue';
import type { InfoItem } from '@views/db-manage/redis/db-data-copy/pages/page1/Index.vue';

import ForceAction from '../force-action/Index.vue';

import RenderDataRow, { createRowData, type IDataRow } from './Row.vue';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@
@remove="handleRemove(index)" />
</template>
</RenderTable>
<div class="force-action">
<BkCheckbox
v-model="isForce"
v-bk-tooltips="t('如忽略,有连接的情况下也会执行强制升级')">
<span class="force-action-text">{{ t('忽略业务连接') }}</span>
</BkCheckbox>
</div>
<ForceAction v-model="isForce" />
<TicketRemark v-model="localRemark" />
<ClusterSelector
v-model:is-show="isShowClusterSelector"
Expand Down Expand Up @@ -106,6 +100,8 @@
import BatchOperateIcon from '@views/db-manage/common/batch-operate-icon/Index.vue';
import type { InfoItem } from '@views/db-manage/redis/db-data-copy/pages/page1/Index.vue';

import ForceAction from '../force-action/Index.vue';

import RenderDataRow, { createRowData, type IDataRow } from './Row.vue';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
isLoading: false,
clusterData,
});
</script>

<script setup lang="ts">
interface Props {
data: IDataRow;
removeable: boolean;
Expand All @@ -88,7 +86,9 @@
interface Exposes {
getValue: () => Promise<any>;
}
</script>

<script setup lang="ts">
const props = defineProps<Props>();

const emits = defineEmits<Emits>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
@click="handleShowMasterBatchSelector" />
</template>
</RenderTableHeadColumn>
<RenderTableHeadColumn
:required="false"
:width="120">
<span>{{ t('主从主机') }}</span>
</RenderTableHeadColumn>
<RenderTableHeadColumn
:required="false"
:width="100">
<span>{{ t('只读主机') }}</span>
</RenderTableHeadColumn>
<RenderTableHeadColumn :width="220">
<span>{{ t('当前版本') }}</span>
</RenderTableHeadColumn>
Expand All @@ -36,7 +46,12 @@
<RenderTableHeadColumn
:min-width="130"
:width="300">
<span>{{ t('新从库主机') }}</span>
<span>{{ t('新主从主机') }}</span>
</RenderTableHeadColumn>
<RenderTableHeadColumn
:min-width="200"
:width="300">
<span>{{ t('新只读主机') }}</span>
</RenderTableHeadColumn>
<RenderTableHeadColumn
fixed="right"
Expand All @@ -57,13 +72,7 @@
@remove="handleRemove(index)" />
</template>
</RenderTable>
<div class="force-action">
<BkCheckbox
v-model="isForce"
v-bk-tooltips="t('如忽略,有连接的情况下也会执行强制升级')">
<span class="force-action-text">{{ t('忽略业务连接') }}</span>
</BkCheckbox>
</div>
<ForceAction v-model="isForce" />
<BkForm
class="storage-remote-form mt-24"
form-type="vertical">
Expand Down Expand Up @@ -127,6 +136,8 @@
import BatchOperateIcon from '@views/db-manage/common/batch-operate-icon/Index.vue';
import type { InfoItem } from '@views/db-manage/redis/db-data-copy/pages/page1/Index.vue';

import ForceAction from '../force-action/Index.vue';

import RenderDataRow, { createRowData, type IDataRow } from './Row.vue';

interface Props {
Expand Down Expand Up @@ -225,6 +236,20 @@
packageVersion: item.masters[0].version,
moduleName: item.db_module_name,
cloudId: item.bk_cloud_id,
masterSlaveList: [...item.masters, ...item.slaves.filter((item) => item.is_stand_by)].map((item) => ({
bk_biz_id: item.bk_biz_id,
bk_host_id: item.bk_host_id,
ip: item.ip,
bk_cloud_id: item.bk_cloud_id,
})),
readonlySlaveList: item.slaves
.filter((item) => !item.is_stand_by)
.map((item) => ({
bk_biz_id: item.bk_biz_id,
bk_host_id: item.bk_host_id,
ip: item.ip,
bk_cloud_id: item.bk_cloud_id,
})),
},
});

Expand Down
Loading

0 comments on commit 94ba015

Please sign in to comment.