diff --git a/dbm-ui/backend/db_monitor/serializers.py b/dbm-ui/backend/db_monitor/serializers.py index 39fb2bdf68..da6a1b58c9 100644 --- a/dbm-ui/backend/db_monitor/serializers.py +++ b/dbm-ui/backend/db_monitor/serializers.py @@ -8,7 +8,6 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import json import urllib.parse from django.utils.translation import gettext_lazy as _ @@ -100,7 +99,9 @@ class MonitorPolicySerializer(AuditedSerializer, serializers.ModelSerializer): event_url = serializers.SerializerMethodField(method_name="get_event_url") def get_event_url(self, obj): - """监控事件跳转链接""" + """ + 监控事件跳转链接 + """ bk_biz_id = obj.bk_biz_id or env.DBA_APP_BK_BIZ_ID query_string = urllib.parse.urlencode( @@ -137,7 +138,9 @@ class Meta: class MonitorPolicyUpdateSerializer(AuditedSerializer, serializers.ModelSerializer): class TargetSerializer(serializers.Serializer): - """告警目标""" + """ + 告警目标 + """ class TargetRuleSerializer(serializers.Serializer): key = serializers.ChoiceField(choices=TargetLevel.get_choices()) @@ -147,7 +150,9 @@ class TargetRuleSerializer(serializers.Serializer): rule = TargetRuleSerializer() class TestRuleSerializer(serializers.Serializer): - """检测规则""" + """ + 检测规则 + """ class TestRuleConfigSerializer(serializers.Serializer): method = serializers.ChoiceField(choices=OperatorEnum.get_choices()) @@ -218,6 +223,10 @@ class ListModuleSerializer(ListClusterSerializer): class AlarmCallBackDataSerializer(serializers.Serializer): + """ + 告警回调数据 + """ + class CallBackMessageSerializer(serializers.Serializer): event = serializers.DictField(help_text=_("告警事件")) strategy = serializers.DictField(help_text=_("监控策略")) @@ -234,19 +243,16 @@ def to_internal_value(self, data): data = super().to_internal_value(data) ticket_types = [] - # 取告警负责人作为单据创建人 - try: - data["creator"] = json.loads(data["appointees"].replace("'", '"'))[0] - except IndexError: - data["creator"] = "system" - # 取关联的的故障自愈处理单据 for label in data["callback_message"].get("labels") or []: if label.startswith("NEED_AUTOFIX"): ticket_type = label.split("/")[1] if ticket_type in TicketType.get_values(): ticket_types.append(ticket_type) + + # 未匹配到故障自愈处理单据 if not ticket_types: raise AutofixException(_("未匹配到对应的故障自愈处理单据,请确认是否配置正确")) - data["ticket_types"] = ticket_types + + data.update({"ticket_types": ticket_types, "creator": "bkmonitor"}) return data diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_build_db_sync_for_autofix.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_build_db_sync_for_autofix.py index 5cf8fc9240..dd9fd4eda0 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_build_db_sync_for_autofix.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_build_db_sync_for_autofix.py @@ -60,3 +60,5 @@ class SQLServerClearFlowBuilder(BaseSQLServerTicketFlowBuilder): inner_flow_builder = SQLServerClearFlowParamBuilder inner_flow_name = _("SQLServer 同步数据") retry_type = FlowRetryType.MANUAL_RETRY + default_need_itsm = False + default_need_manual_confirm = False