Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(dbm-services): 获取升级包函数默认参数 #8634 #8635

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dbm-ui/backend/db_services/mysql/toolbox/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion dbm-ui/backend/db_services/mysql/toolbox/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 8 additions & 2 deletions dbm-ui/backend/db_services/mysql/toolbox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading