Skip to content

Commit

Permalink
fix(backend): Redis容量变更调整 #6209
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud authored and zhangzhw8 committed Aug 14, 2024
1 parent 961f257 commit 8c6e4db
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dbm-ui/backend/db_periodic_task/local_tasks/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def auto_retry_exclusive_inner_flow():
TicketTask.retry_exclusive_inner_flow()


@register_periodic_task(run_every=crontab(minute=3, hour=2))
@register_periodic_task(run_every=crontab(minute=0, hour=6))
def auto_create_data_repair_ticket():
TicketTask.auto_create_data_repair_ticket()

Expand Down
18 changes: 18 additions & 0 deletions dbm-ui/backend/db_services/redis/toolbox/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,21 @@ class GetClusterVersionSerializer(serializers.Serializer):
cluster_id = serializers.IntegerField(help_text=_("集群ID"))
node_type = serializers.ChoiceField(help_text=_("集群节点类型"), choices=RedisVerUpdateNodeType.get_choices())
type = serializers.ChoiceField(help_text=_("请求版本类型"), choices=RedisVersionQueryType.get_choices())


class GetClusterCapacityInfoSerializer(serializers.Serializer):
cluster_id = serializers.IntegerField(help_text=_("集群ID"))
new_storage_version = serializers.CharField(help_text=_("存储版本"))
new_spec_id = serializers.IntegerField(help_text=_("新规格ID"))
new_machine_group_count = serializers.IntegerField(help_text=_("申请机器组数量"))
new_shards_num = serializers.IntegerField(help_text=_("新的分片数量"))

class Meta:
swagger_schema_fields = {
"example": {
"capacity_update_type": "keep_current_machines",
"require_spec_id": 1,
"require_machine_group_num": 3,
"err_msg": "",
}
}
12 changes: 12 additions & 0 deletions dbm-ui/backend/db_services/redis/toolbox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
from backend.db_services.redis.constants import RedisVersionQueryType
from backend.db_services.redis.toolbox.handlers import ToolboxHandler
from backend.db_services.redis.toolbox.serializers import (
GetClusterCapacityInfoSerializer,
GetClusterVersionSerializer,
QueryByOneClusterSerializer,
QueryClusterIpsSerializer,
)
from backend.flow.utils.redis.redis_proxy_util import get_cluster_capacity_update_required_info
from backend.iam_app.handlers.drf_perm.base import DBManagePermission

SWAGGER_TAG = "db_services/redis/toolbox"
Expand Down Expand Up @@ -81,3 +83,13 @@ def get_cluster_versions(self, request, bk_biz_id, **kwargs):
return Response(ToolboxHandler.get_online_cluster_versions(cluster_id, node_type))
else:
return Response(ToolboxHandler.get_update_cluster_versions(cluster_id, node_type))

@common_swagger_auto_schema(
operation_summary=_("获取集群容量变更所需信息"),
query_serializer=GetClusterCapacityInfoSerializer(),
tags=[SWAGGER_TAG],
)
@action(methods=["GET"], detail=False, serializer_class=GetClusterCapacityInfoSerializer, pagination_class=None)
def get_cluster_capacity_update_info(self, request, bk_biz_id, **kwargs):
data = self.params_validate(self.get_serializer_class())
return Response(get_cluster_capacity_update_required_info(**data))
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from backend.configuration.constants import AffinityEnum
from backend.db_services.dbbase.constants import IpSource
from backend.flow.consts import RedisCapacityUpdateType
from backend.flow.engine.controller.redis import RedisController
from backend.ticket import builders
from backend.ticket.builders.common.base import BaseOperateResourceParamBuilder, SkipToRepresentationMixin
Expand All @@ -39,12 +40,13 @@ class BackendGroupSerializer(serializers.Serializer):
shard_num = serializers.IntegerField(help_text=_("集群分片数"))
group_num = serializers.IntegerField(help_text=_("部署机器组数"))
db_version = serializers.CharField(help_text=_("版本号"))
capacity = serializers.IntegerField(help_text=_("当前容量需求"))
future_capacity = serializers.IntegerField(help_text=_("未来容量需求"))
online_switch_type = serializers.ChoiceField(
help_text=_("切换类型"), choices=SwitchConfirmType.get_choices(), default=SwitchConfirmType.NO_CONFIRM
)
update_mode = serializers.ChoiceField(help_text=_("容量变更类型"), choices=RedisCapacityUpdateType.get_choices())
resource_spec = ResourceSpecSerializer(help_text=_("资源申请"))
capacity = serializers.IntegerField(help_text=_("当前容量需求"))
future_capacity = serializers.IntegerField(help_text=_("未来容量需求"))

ip_source = serializers.ChoiceField(help_text=_("主机来源"), choices=IpSource.get_choices())
infos = serializers.ListField(help_text=_("批量操作参数列表"), child=InfoSerializer())
Expand Down

0 comments on commit 8c6e4db

Please sign in to comment.