diff --git a/dbm-ui/backend/db_services/mysql/toolbox/handlers.py b/dbm-ui/backend/db_services/mysql/toolbox/handlers.py index 4032204108..63ff549911 100644 --- a/dbm-ui/backend/db_services/mysql/toolbox/handlers.py +++ b/dbm-ui/backend/db_services/mysql/toolbox/handlers.py @@ -37,8 +37,7 @@ def __init__(self): # txsql pkg name: mysql-txsql-8.0.30-20230701-linux-x86_64.tar.gz # 社区版本 pkg name: mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz - def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: bool): - higher_major_version = True + def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: bool, higher_all_version: bool): cluster = Cluster.objects.filter(id=cluster_id).get() instance = StorageInstance.objects.filter( cluster=cluster, @@ -75,6 +74,7 @@ def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: b self.filter_available_packages( pkg, higher_major_version, + higher_all_version, major_version_num, pkg_major_vesion_num, sub_version_num, @@ -94,6 +94,7 @@ def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: b self.filter_available_packages( pkg, higher_major_version, + higher_all_version, major_version_num, pkg_major_vesion_num, sub_version_num, @@ -106,6 +107,7 @@ def query_higher_version_pkg_list(self, cluster_id: int, higher_major_version: b self.filter_available_packages( pkg, higher_major_version, + higher_all_version, major_version_num, pkg_major_vesion_num, sub_version_num, @@ -125,6 +127,7 @@ def filter_available_packages( self, pkg: Package, higher_major_version: bool, + higher_all_version: bool, refer_version_num: int, current_version_num: int, refer_sub_version_num: int, @@ -142,6 +145,13 @@ def filter_available_packages( and (current_sub_version_num > refer_sub_version_num) ): self.available_pkg_list.append(pkg) + # higher_all_version 表示需要获取大小版本都可以使用的包 + if ( + higher_all_version + and (current_version_num == refer_version_num) + and (current_sub_version_num > refer_sub_version_num) + ): + self.available_pkg_list.append(pkg) def convert_mysql8_version_num(major_version: int) -> int: diff --git a/dbm-ui/backend/db_services/mysql/toolbox/serializers.py b/dbm-ui/backend/db_services/mysql/toolbox/serializers.py index e8600457cd..7b6d256c47 100644 --- a/dbm-ui/backend/db_services/mysql/toolbox/serializers.py +++ b/dbm-ui/backend/db_services/mysql/toolbox/serializers.py @@ -20,9 +20,10 @@ class QueryPkgListByCompareVersionSerializer(serializers.Serializer): cluster_id = serializers.IntegerField() higher_major_version = serializers.BooleanField(default=False) + higher_all_version = serializers.BooleanField(default=False) class Meta: - swagger_schema_fields = {"cluster_id": 123, "higher_major_version": False} + swagger_schema_fields = {"cluster_id": 123, "higher_major_version": False, "higher_all_version": False} class TendbhaTransferToOtherBizSerializer(serializers.Serializer): diff --git a/dbm-ui/backend/db_services/mysql/toolbox/views.py b/dbm-ui/backend/db_services/mysql/toolbox/views.py index 5782d8bc01..d444a3af50 100644 --- a/dbm-ui/backend/db_services/mysql/toolbox/views.py +++ b/dbm-ui/backend/db_services/mysql/toolbox/views.py @@ -51,8 +51,14 @@ class ToolboxViewSet(viewsets.SystemViewSet): @action(methods=["POST"], detail=False, serializer_class=QueryPkgListByCompareVersionSerializer) def query_higher_version_pkg_list(self, request, **kwargs): data = self.params_validate(self.get_serializer_class()) - cluster_id, higher_major_version = data["cluster_id"], data["higher_major_version"] - return Response(ToolboxHandler().query_higher_version_pkg_list(cluster_id, higher_major_version)) + cluster_id, higher_major_version, higher_all_version = ( + data["cluster_id"], + data["higher_major_version"], + data["higher_all_version"], + ) + return Response( + ToolboxHandler().query_higher_version_pkg_list(cluster_id, higher_major_version, higher_all_version) + ) class TendbHaSlaveInstanceAddDomainSet(viewsets.SystemViewSet):