Skip to content

Commit

Permalink
fix(backend): mysql,tendbcluster实例状态异常可切换主机 #9010
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcyao authored and zhangzhw8 committed Jan 10, 2025
1 parent e6291cb commit 41bb42d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from backend.flow.engine.controller.spider import SpiderController
from backend.ticket import builders
from backend.ticket.builders.tendbcluster.base import BaseTendbTicketFlowBuilder
from backend.ticket.builders.tendbcluster.base import BaseTendbTicketFlowBuilder, TendbBaseOperateDetailSerializer
from backend.ticket.builders.tendbcluster.tendb_master_slave_switch import TendbMasterSlaveSwitchDetailSerializer
from backend.ticket.constants import TicketType

Expand All @@ -24,6 +24,8 @@ class TendbMasterFailOverDetailSerializer(TendbMasterSlaveSwitchDetailSerializer
serializers.BooleanField(help_text=_("是否检测数据同步延时情况"))

def validate(self, attrs):
# 校验集群是否可用,集群类型为tendbcluster
super(TendbBaseOperateDetailSerializer, self).validate_cluster_can_access(attrs)
if not attrs["force"]:
raise serializers.ValidationError(_("主故障切换场景需要强制执行"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
from backend.ticket.builders.common.base import BaseOperateResourceParamBuilder, HostInfoSerializer
from backend.ticket.builders.common.constants import MySQLBackupSource
from backend.ticket.builders.mysql.mysql_restore_slave import MysqlRestoreSlaveDetailSerializer
from backend.ticket.builders.tendbcluster.base import BaseTendbTicketFlowBuilder
from backend.ticket.builders.tendbcluster.base import BaseTendbTicketFlowBuilder, TendbBaseOperateDetailSerializer
from backend.ticket.constants import TicketType
from backend.utils.basic import get_target_items_from_details


class TendbClusterRestoreSlaveDetailSerializer(MysqlRestoreSlaveDetailSerializer):
class TendbClusterRestoreSlaveDetailSerializer(MysqlRestoreSlaveDetailSerializer, TendbBaseOperateDetailSerializer):
class RestoreInfoSerializer(serializers.Serializer):
old_slave = HostInfoSerializer(help_text=_("旧从库 IP"))
new_slave = HostInfoSerializer(help_text=_("新从库 IP"), required=False)
Expand All @@ -41,7 +41,7 @@ class RestoreInfoSerializer(serializers.Serializer):

def validate(self, attrs):
# 校验集群是否可用,集群类型为tendbcluster
super(MysqlRestoreSlaveDetailSerializer, self).validate_cluster_can_access(attrs)
super(TendbBaseOperateDetailSerializer, self).validate_cluster_can_access(attrs)
super(MysqlRestoreSlaveDetailSerializer, self).validated_cluster_type(attrs, ClusterType.TenDBCluster)
# 校验新机器的云区域与集群一致
if attrs["ip_source"] == IpSource.MANUAL_INPUT:
Expand Down

0 comments on commit 41bb42d

Please sign in to comment.