diff --git a/dbm-ui/backend/db_services/mysql/toolbox/handlers.py b/dbm-ui/backend/db_services/mysql/toolbox/handlers.py index 63ff549911..8e941c3076 100644 --- a/dbm-ui/backend/db_services/mysql/toolbox/handlers.py +++ b/dbm-ui/backend/db_services/mysql/toolbox/handlers.py @@ -70,7 +70,7 @@ def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: b # tmysql 可用用mysql 官方社区版本的介质 if re.search(tmysql_re_pattern, pkg.name) or (not re.search(pkgname_txsql_re_pattern, pkg.name)): # higger_major_version:需要更高的主版本,无需比较子版本 - if higher_major_version: + if higher_major_version or higher_all_version: self.filter_available_packages( pkg, higher_major_version, @@ -80,6 +80,15 @@ def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: b sub_version_num, pkg_sub_version_num, ) + # 判断tmysql的子版本 + if ( + higher_all_version + and pkg_major_vesion_num == major_version_num + and pkg_sub_version_num == sub_version_num + ): + tmysql_pkg_sub_version_num = tmysql_version_parse(pkg.name) + if tmysql_pkg_sub_version_num > tmysql_sub_version_num: + self.available_pkg_list.append(pkg) continue else: if pkg_major_vesion_num == major_version_num: @@ -103,7 +112,9 @@ def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: b # 统一当做社区版本来处理 else: - if (not re.search(pkgname_txsql_re_pattern, pkg.name)) and (re.search(tmysql_re_pattern, pkg.name)): + if (not re.search(pkgname_txsql_re_pattern, pkg.name)) and ( + not re.search(tmysql_re_pattern, pkg.name) + ): self.filter_available_packages( pkg, higher_major_version, @@ -136,7 +147,9 @@ def filter_available_packages( """ 根据包类型、版本号和是否要求更高主版本来过滤包列表 """ - if higher_major_version and just_cross_one_major_version(current_version_num, refer_version_num): + if (higher_major_version or higher_all_version) and just_cross_one_major_version( + current_version_num, refer_version_num + ): self.available_pkg_list.append(pkg) else: if ( diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_upgrade.py b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_upgrade.py index 939458dbdf..5d7e694469 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_upgrade.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/mysql/mysql_upgrade.py @@ -140,7 +140,7 @@ class MySQLStorageLocalUpgradeFlow(object): cluster_ids:[], cluster_type:"", new_mysql_version:"", - new_module_id:"" + new_db_module_id:"" } ] } @@ -155,6 +155,7 @@ def __init__(self, root_id: str, ticket_data: Optional[Dict]): self.data = ticket_data self.uid = ticket_data["uid"] self.upgrade_cluster_list = ticket_data["infos"] + self.new_db_module_id = ticket_data.get("new_db_module_id", -1) def __the_clusters_use_same_machine(self, cluster_ids: list): clusters = Cluster.objects.filter(id__in=cluster_ids) @@ -225,6 +226,7 @@ def upgrade_mysql_flow(self): if first_cluster: cluster_type = first_cluster.cluster_type bk_cloud_id = first_cluster.bk_cloud_id + bk_biz_id = first_cluster.bk_biz_id # 高可用升级 if cluster_type == ClusterType.TenDBHA: slave_instances = self.__get_clusters_slave_instance(cluster_ids) @@ -366,8 +368,25 @@ def upgrade_mysql_flow(self): pkg_id=pkg_id, ) ) - + # 更新集群模块信息 + if self.new_db_module_id > 0: + charset, major_version = get_version_and_charset(bk_biz_id, self.new_db_module_id, cluster_type) + sub_pipeline.add_act( + act_name=_("更新集群db模块信息"), + act_component_code=MySQLDBMetaComponent.code, + kwargs=asdict( + DBMetaOPKwargs( + db_meta_class_func=MySQLDBMeta.update_cluster_module.__name__, + cluster={ + "cluster_ids": cluster_ids, + "new_module_id": self.new_db_module_id, + "major_version": major_version, + }, + ) + ), + ) sub_pipelines.append(sub_pipeline.build_sub_process(sub_name=_("[TendbSingle]本地升级MySQL版本"))) + else: raise DBMetaException(message=_("不支持的集群类型"))