From d9120385b05a85cc28b32f818847a348d1c973ad Mon Sep 17 00:00:00 2001 From: iSecloud <869820505@qq.com> Date: Thu, 12 Dec 2024 17:04:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(backend):=20=E5=8D=95=E6=8D=AE=E4=BA=92?= =?UTF-8?q?=E6=96=A5=E5=8F=AF=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9=20&=20?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=20#8576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/configuration/constants.py | 1 + dbm-ui/backend/configuration/models/system.py | 2 +- dbm-ui/backend/ticket/apps.py | 2 ++ .../ticket/builders/mysql/mysql_dump_data.py | 24 ++++++++----- dbm-ui/backend/ticket/exclusive_ticket.xlsx | Bin 32576 -> 32743 bytes dbm-ui/backend/ticket/models/ticket.py | 34 ++++++++++-------- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/dbm-ui/backend/configuration/constants.py b/dbm-ui/backend/configuration/constants.py index 0b8a8824bf..9a77ceadfe 100644 --- a/dbm-ui/backend/configuration/constants.py +++ b/dbm-ui/backend/configuration/constants.py @@ -113,6 +113,7 @@ class SystemSettingsEnum(str, StructuredEnum): AFFINITY = EnumField("AFFINITY", _("容灾要求(各个环境可能不同,比如SG为空)")) SYSTEM_MSG_TYPE = EnumField("SYSTEM_MSG_TYPE", _("系统消息通知方式")) PADDING_PROXY_CLUSTER_LIST = EnumField("PADDING_PROXY_CLUSTER_LIST", _("补全proxy的集群域名列表")) + EXCLUSIVE_TICKET_MAP = EnumField("EXCLUSIVE_TICKET_MAP", _("单据互斥表(全局)")) # ITSM配置 BK_ITSM_SERVICE_ID = EnumField("BK_ITSM_SERVICE_ID", _("DBM的流程服务ID")) ITSM_APPROVAL_KEY = EnumField("ITSM_APPROVAL_KEY", _("ITSM审批意见key")) diff --git a/dbm-ui/backend/configuration/models/system.py b/dbm-ui/backend/configuration/models/system.py index d26b3bd82d..9698f1b66c 100644 --- a/dbm-ui/backend/configuration/models/system.py +++ b/dbm-ui/backend/configuration/models/system.py @@ -117,7 +117,7 @@ def insert_setting_value(cls, key: str, value: Any, value_type: str = "str", use ) @classmethod - def get_external_whitelist_cluster_ids(cls) -> List[int]: + def get_external_whitelist_cluster_ids(cls) -> List: return [ conf["cluster_id"] for conf in cls.get_setting_value( diff --git a/dbm-ui/backend/ticket/apps.py b/dbm-ui/backend/ticket/apps.py index 70cc495143..8fedb2a5d2 100644 --- a/dbm-ui/backend/ticket/apps.py +++ b/dbm-ui/backend/ticket/apps.py @@ -18,9 +18,11 @@ def init_ticket_flow_config(sender, **kwargs): from backend.ticket.handler import TicketHandler + from backend.ticket.models import ClusterOperateRecord try: TicketHandler.ticket_flow_config_init() + ClusterOperateRecord.objects.get_exclusive_ticket_map(force=True) except Exception as err: # pylint: disable=broad-except: logger.warning(f"ticket_flow_config_init occur error, {err}") diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_dump_data.py b/dbm-ui/backend/ticket/builders/mysql/mysql_dump_data.py index 9b6f6efdc5..5d070b030d 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_dump_data.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_dump_data.py @@ -36,17 +36,16 @@ class MySQLDumpDataDetailSerializer(MySQLBaseOperateDetailSerializer): dump_data = serializers.BooleanField(help_text=_("是否导出表数据")) force = serializers.BooleanField(help_text=_("是否强制执行"), default=False) + def to_internal_value(self, data): + data = super().to_internal_value(data) + data["is_external"] = getattr(self.context["request"], "is_external", False) + return data + class MySQLDumpDataItsmFlowParamsBuilder(builders.ItsmParamBuilder): - def get_params(self): - params = super().get_params() - bk_biz_id = self.ticket.bk_biz_id - # 数据导出的审批人是该业务下的产品,如果没有产品则按照原来审批人 - approve_index = [field["key"] for field in params["fields"]].index("approver") - old_approver = params["fields"].pop(approve_index)["value"] - biz_productor = AppCache.get_app_attr_from_cc(bk_biz_id, attr_name="bk_biz_productor") or old_approver - params["fields"].append({"key": "approver", "value": biz_productor}) - return params + def get_approvers(self): + bk_biz_maintainer = AppCache.get_app_attr_from_cc(self.ticket.bk_biz_id, attr_name="bk_biz_maintainer") + return bk_biz_maintainer or super().get_approvers() class MySQLDumpDataFlowParamBuilder(builders.FlowParamBuilder): @@ -77,3 +76,10 @@ class MySQLDumpDataFlowBuilder(BaseMySQLTicketFlowBuilder): inner_flow_builder = MySQLDumpDataFlowParamBuilder inner_flow_name = _("数据导出执行") itsm_flow_builder = MySQLDumpDataItsmFlowParamsBuilder + + @property + def need_itsm(self): + # 1. 导出数据和表结构 :运维人员审批 + # 2.导出数据 :运维人员审批 + # 3.导出表结构 :正常情况 - 不需要审批,PO环境 - 运维人员审批 + return self.ticket.details["dump_data"] or self.ticket.details["is_external"] diff --git a/dbm-ui/backend/ticket/exclusive_ticket.xlsx b/dbm-ui/backend/ticket/exclusive_ticket.xlsx index 8087278412047b1f604d411c9b889a1d5d6e0f74..ada7c063a11f8ea3a33c3212caa6b79b31ed3be7 100644 GIT binary patch delta 12964 zcmch8bzGF&+BP7FBLWH{N*XjuNVf<|hoqDv2!kNqGr&AbN{%?vDJVz|k|HG~UDDm% z-OT&o-upf7{hb{@&v`%oSS+4r&2?YbweI^~6U>)m+!-uxb|)^urL!IgEp#6)8=%xb zXY+RHPHh(d`3#m}?@0^x0y(+c#ib$6jYya8{)aj&~J>n%O83^865(VnYc1ufwqt^2<(d0b7U8JJ1(mWDx=`@Q(TWH zED88##3Y{Qu@1Lpza7HgDxGe=U3k#Y?9fJ=L$Fd=R>}j1W-JJQkjeDfAYGfVv+W6< zpULT?Abj)HLp|$-&ijrg%T7N8PfcNvZ6KjxZk@-KVh0iE)YYt=x$C|dRAH-p&(38m z3GJuYq$JPPm@7-uf=r}I(K`GxX3~juq&I+zFyp&P+>Dc{@PkR@lYVy=($iRSPA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N-(FiFK5jEjO7}QqC!@=3+k%NQH z(FdNxb%tLI37_%J>jj=4oWA|Ukv88y@EyNk7JXWgufmv_f&jB@ablouAF#q{6m6~8 z02hNxTiVOBj$pJWs{AF4nlG*`Tz0w!c%IUxpXF8cX6s^$ZCKZ+6H`=v7E58kBI9fjE%$+Lag1W}l*N+3Iq0p-*=_XZQovBSXmrLwTzWr|geM@|8l+rxtSo9s2V z7o2A1KNX~CO*i@*XE@Bp7@%tMvHV}lLdoPF(z8bQqIchb*z;az``bJ(%M6gb{MB4i zcU3U7G@IrHt&F9Each#2liPYfX@wgVRo|CK^cgjWHeUo7VDl|4vJAW1gqJk4w)caV zAH0?w_7Y%o;ZufQL*vdI4Q`BHd-4el?Ub)As&l0MQE(>;jw9Q?MI!|@l_OOnLx!Tgw$C0^sRns5$$WYu{ z2`{wDUvrnlp7OMwsvJD^>*{j=WIF=JxhDu_U~~^V)HUD-jVq+4~$E(wt`U+DJIAy$R+ zcwamD`uH~o!a=^w@DT6QBw23oIPWVY-EQzMZ)M`+@bf-AO#gXLfQX3j*1)$PVj?!e z-#ECTj|{OkJjzFc#LE!AW=Ide0i0p}Z;KzT_;~@=34YpFmbeyv%l9JlA3yVdH0jrA znBzy^0Dvd>3Xz-?`8J#+4C!RQ4PVQW!Ug^KNW|s8J^Uz7dISo8=68XF`}()1iu{B~ y&MSQz?h%H^RlW_c0YW6ZHwi-}l1=Sz&pgo~J*TBcdg2I}k?<=?7;Qk09{nFLcW4~| diff --git a/dbm-ui/backend/ticket/models/ticket.py b/dbm-ui/backend/ticket/models/ticket.py index c96287be4d..ef40b5bb84 100644 --- a/dbm-ui/backend/ticket/models/ticket.py +++ b/dbm-ui/backend/ticket/models/ticket.py @@ -20,7 +20,8 @@ from backend import env from backend.bk_web.constants import LEN_L_LONG, LEN_LONG, LEN_NORMAL, LEN_SHORT from backend.bk_web.models import AuditedModel -from backend.configuration.constants import PLAT_BIZ_ID, DBType +from backend.configuration.constants import PLAT_BIZ_ID, DBType, SystemSettingsEnum +from backend.configuration.models import SystemSettings from backend.db_monitor.exceptions import AutofixException from backend.ticket.constants import ( EXCLUSIVE_TICKET_EXCEL_PATH, @@ -272,13 +273,13 @@ def filter_actives(self, cluster_id, *args, **kwargs): return self.filter(cluster_id=cluster_id, ticket__status=TicketFlowStatus.RUNNING, *args, **kwargs) def filter_inner_actives(self, cluster_id, *args, **kwargs): - """获取集群正在运行的inner flow的单据记录。此时认为集群会在互斥阶段""" + """获取集群正在 运行/失败 的inner flow的单据记录。此时认为集群会在互斥阶段""" # 排除特定的单据,如自身单据重试排除自身 exclude_ticket_ids = kwargs.pop("exclude_ticket_ids", []) return self.filter( cluster_id=cluster_id, flow__flow_type=FlowType.INNER_FLOW, - flow__status=TicketFlowStatus.RUNNING, + flow__status__in=[TicketFlowStatus.RUNNING, TicketFlowStatus.FAILED], *args, **kwargs, ).exclude(flow__ticket_id__in=exclude_ticket_ids) @@ -290,28 +291,33 @@ def get_cluster_operations(self, cluster_id, **kwargs): def has_exclusive_operations(self, ticket_type, cluster_id, **kwargs): """判断当前单据类型与集群正在进行中的单据是否互斥""" active_records = self.filter_inner_actives(cluster_id, **kwargs) + exclusive_ticket_map = self.get_exclusive_ticket_map() exclusive_infos = [] for record in active_records: active_ticket_type = record.ticket.ticket_type # 记录互斥信息。不存在互斥表默认为互斥 - if self.exclusive_ticket_map[ticket_type].get(active_ticket_type, True): + if exclusive_ticket_map[ticket_type].get(active_ticket_type, True): exclusive_infos.append({"exclusive_ticket": record.ticket, "root_id": record.flow.flow_obj_id}) return exclusive_infos - @property - def exclusive_ticket_map(self): - if hasattr(self, "_exclusive_ticket_map"): - return self._exclusive_ticket_map + @staticmethod + def get_exclusive_ticket_map(force=False): + """获取单据互斥状态表, force为True表示强制刷新""" + exclusive_map = SystemSettings.get_setting_value(key=SystemSettingsEnum.EXCLUSIVE_TICKET_MAP, default={}) + if exclusive_map and not force: + return exclusive_map - _exclusive_matrix = ExcelHandler.paser_matrix(EXCLUSIVE_TICKET_EXCEL_PATH) - _exclusive_ticket_map = defaultdict(dict) - for row_label, inner_dict in _exclusive_matrix.items(): + exclusive_map = defaultdict(dict) + exclusive_matrix = ExcelHandler.paser_matrix(EXCLUSIVE_TICKET_EXCEL_PATH) + for row_label, inner_dict in exclusive_matrix.items(): for col_label, value in inner_dict.items(): row_key, col_key = TicketType.get_choice_value(row_label), TicketType.get_choice_value(col_label) - _exclusive_ticket_map[row_key][col_key] = value == "N" + exclusive_map[row_key][col_key] = value == "N" - setattr(self, "_exclusive_ticket_map", _exclusive_ticket_map) - return self._exclusive_ticket_map + SystemSettings.insert_setting_value( + key=SystemSettingsEnum.EXCLUSIVE_TICKET_MAP, value=exclusive_map, value_type="dict" + ) + return exclusive_map class ClusterOperateRecord(AuditedModel):