From 7eb0b3bba432fe1b2283cf8674c3e2645765a531 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 14:41:03 +0800 Subject: [PATCH 1/7] =?UTF-8?q?bugfix:=20=E5=85=A8=E5=B1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E9=A2=84=E8=A7=88=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E4=BB=8D=E6=8F=90=E7=A4=BA=E5=8F=91=E9=80=81=E6=88=90=E5=8A=9F?= =?UTF-8?q?=20#1225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../i18n/exception/message.properties | 7 +++- .../i18n/exception/message_en.properties | 7 +++- .../i18n/exception/message_en_US.properties | 7 +++- .../i18n/exception/message_zh.properties | 7 +++- .../i18n/exception/message_zh_CN.properties | 7 +++- .../bk/job/common/constant/ErrorCode.java | 16 +++++--- .../common/paas/exception/PaasException.java | 40 +++++++++++++++++++ .../bk/job/common/paas/user/EEPaasClient.java | 16 +++++--- .../bk/job/common/paas/user/IPaasClient.java | 3 +- .../web/service/impl/LoginServiceImpl.java | 2 +- .../api/web/WebGlobalSettingsResource.java | 4 +- .../impl/ServiceNotificationResourceImpl.java | 4 +- .../impl/WebGlobalSettingsResourceImpl.java | 2 +- .../notify/impl/NotifyEsbChannelDAOImpl.java | 2 +- .../bk/job/manage/service/NotifyService.java | 8 ++-- .../bk/job/manage/service/PaaSService.java | 4 +- .../impl/GlobalSettingsServiceImpl.java | 24 ++++++----- .../manage/service/impl/PaaSServiceImpl.java | 6 +-- .../service/impl/WatchableSendMsgService.java | 11 ++--- .../impl/notify/NotifySendService.java | 36 +++++++++++++++-- .../impl/notify/NotifyServiceImpl.java | 20 +++++----- .../service/impl/notify/SendNotifyTask.java | 35 +++++++++------- 22 files changed, 184 insertions(+), 84 deletions(-) create mode 100644 src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/exception/PaasException.java diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties index 83df1ee47f..15111d92ee 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties @@ -72,8 +72,11 @@ 1211002=CMDB API返回数据异常 1211003=根据动态分组ID查找主机失败,动态分组ID:{0},原因:{1},请确认指定的动态分组在业务下是否存在 1211004=根据业务ID查找动态分组失败,业务ID:{0},原因:{1},请确认指定的业务是否存在动态分组 -1213001=PAAS 服务不可用 -1213002=PAAS API返回数据异常 +1213001=CMSI接口访问异常 +1213002=用户管理接口访问异常 +1213003=调用CMSI接口获取通知渠道数据异常 +1213004=调用CMSI接口发送通知失败,原因:{0} + 1214001=ARTIFACTORY API返回数据异常 1214002=制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties index 96262944b9..973da5d935 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties @@ -72,8 +72,11 @@ 1211002=CMDB API returned data exception 1211003=Fail to find host by dynamic group, id:{0}, reason:{1}, please confirm the specified dynamic group in business 1211004=Fail to find dynamic group by biz, id:{0}, reason:{1}, please confirm dynamic group in the specified business -1213001=PAAS service is unavailable -1213002=PAAS API returned data exception +1213001=Fail to request CMSI API +1213002=Fail to request UserManage API +1213003=CMSI exception when get notify channels +1213004=CMSI exception when send notify, reason:{0} + 1214001=ARTIFACTORY API returned data exception 1214002=Cannot find node in bkrepo:{0}, please check in bkrepo diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties index 96262944b9..973da5d935 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties @@ -72,8 +72,11 @@ 1211002=CMDB API returned data exception 1211003=Fail to find host by dynamic group, id:{0}, reason:{1}, please confirm the specified dynamic group in business 1211004=Fail to find dynamic group by biz, id:{0}, reason:{1}, please confirm dynamic group in the specified business -1213001=PAAS service is unavailable -1213002=PAAS API returned data exception +1213001=Fail to request CMSI API +1213002=Fail to request UserManage API +1213003=CMSI exception when get notify channels +1213004=CMSI exception when send notify, reason:{0} + 1214001=ARTIFACTORY API returned data exception 1214002=Cannot find node in bkrepo:{0}, please check in bkrepo diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties index 83df1ee47f..15111d92ee 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties @@ -72,8 +72,11 @@ 1211002=CMDB API返回数据异常 1211003=根据动态分组ID查找主机失败,动态分组ID:{0},原因:{1},请确认指定的动态分组在业务下是否存在 1211004=根据业务ID查找动态分组失败,业务ID:{0},原因:{1},请确认指定的业务是否存在动态分组 -1213001=PAAS 服务不可用 -1213002=PAAS API返回数据异常 +1213001=CMSI接口访问异常 +1213002=用户管理接口访问异常 +1213003=调用CMSI接口获取通知渠道数据异常 +1213004=调用CMSI接口发送通知失败,原因:{0} + 1214001=ARTIFACTORY API返回数据异常 1214002=制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties index 83df1ee47f..15111d92ee 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties @@ -72,8 +72,11 @@ 1211002=CMDB API返回数据异常 1211003=根据动态分组ID查找主机失败,动态分组ID:{0},原因:{1},请确认指定的动态分组在业务下是否存在 1211004=根据业务ID查找动态分组失败,业务ID:{0},原因:{1},请确认指定的业务是否存在动态分组 -1213001=PAAS 服务不可用 -1213002=PAAS API返回数据异常 +1213001=CMSI接口访问异常 +1213002=用户管理接口访问异常 +1213003=调用CMSI接口获取通知渠道数据异常 +1213004=调用CMSI接口发送通知失败,原因:{0} + 1214001=ARTIFACTORY API返回数据异常 1214002=制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java b/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java index a3d5b04734..2c3aa1691a 100644 --- a/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java +++ b/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java @@ -388,12 +388,16 @@ public class ErrorCode { public static final int FAIL_TO_FIND_DYNAMIC_GROUP_BY_BIZ = 1211004; // PaaS异常 - // PAAS服务不可达 - 地址配置错误或者地址无法正确解析 - public static final int PAAS_UNREACHABLE_SERVER = 1213001; - // paas接口返回数据结构异常-一般是被网关防火墙重定向返回统一登录页面 - public static final int PAAS_API_DATA_ERROR = 1213002; - // paas通知渠道接口数据获取异常 - public static final int PAAS_MSG_CHANNEL_DATA_ERROR = 1213003; + // CMSI接口访问异常 + public static final int CMSI_API_ACCESS_ERROR = 1213001; + // 用户管理接口访问异常 + public static final int USER_MANAGE_API_ACCESS_ERROR = 1213002; + // 调用CMSI接口获取通知渠道数据异常 + public static final int CMSI_MSG_CHANNEL_DATA_ERROR = 1213003; + // 调用CMSI接口发送通知失败,原因:{0} + public static final int CMSI_FAIL_TO_SEND_MSG = 1213004; + + // 制品库异常 // Artifactory接口返回数据结构异常 public static final int ARTIFACTORY_API_DATA_ERROR = 1214001; // 制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/exception/PaasException.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/exception/PaasException.java new file mode 100644 index 0000000000..e8f343c943 --- /dev/null +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/exception/PaasException.java @@ -0,0 +1,40 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.common.paas.exception; + +import com.tencent.bk.job.common.exception.ServiceException; +import com.tencent.bk.job.common.model.error.ErrorType; + +public class PaasException extends ServiceException { + + public PaasException(ErrorType errorType, Integer errorCode, Object[] errorParams) { + super(errorType, errorCode, errorParams); + } + + public PaasException(Throwable cause, ErrorType errorType, Integer errorCode, Object[] errorParams) { + super(cause, errorType, errorCode, errorParams); + } + +} diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java index e575664f0c..7cdf5f8018 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java @@ -33,6 +33,8 @@ import com.tencent.bk.job.common.exception.InternalException; import com.tencent.bk.job.common.metrics.CommonMetricNames; import com.tencent.bk.job.common.model.dto.BkUserDTO; +import com.tencent.bk.job.common.model.error.ErrorType; +import com.tencent.bk.job.common.paas.exception.PaasException; import com.tencent.bk.job.common.paas.metrics.PaaSMetricTags; import com.tencent.bk.job.common.paas.model.EsbListUsersResult; import com.tencent.bk.job.common.paas.model.EsbNotifyChannelDTO; @@ -113,7 +115,7 @@ public List getUserList(String fields, } catch (Exception e) { String errorMsg = "Get " + API_GET_USER_LIST + " error"; log.error(errorMsg, e); - throw new InternalException(errorMsg, e, ErrorCode.PAAS_API_DATA_ERROR); + throw new InternalException(errorMsg, e, ErrorCode.USER_MANAGE_API_ACCESS_ERROR); } finally { HttpMetricUtil.clearHttpMetric(); } @@ -170,7 +172,7 @@ public List getNotifyChannelList(String uin) { } @Override - public boolean sendMsg( + public void sendMsg( String msgType, String sender, Set receivers, @@ -194,14 +196,18 @@ public boolean sendMsg( if (esbResp.getResult() == null || !esbResp.getResult() || esbResp.getCode() != 0) { status = checkRespAndGetStatus(uri, esbResp); - return false; + throw new PaasException( + ErrorType.FAILED_PRECONDITION, + ErrorCode.CMSI_FAIL_TO_SEND_MSG, + new Object[]{ + esbResp.getMessage() + }); } status = EsbMetricTags.VALUE_STATUS_SUCCESS; - return true; } catch (Exception e) { log.error("Fail to request {}", uri, e); status = EsbMetricTags.VALUE_STATUS_ERROR; - return false; + throw new PaasException(e, ErrorType.FAILED_PRECONDITION, ErrorCode.CMSI_API_ACCESS_ERROR, new Object[]{}); } finally { HttpMetricUtil.clearHttpMetric(); recordMetrics(start, status, msgType); diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/IPaasClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/IPaasClient.java index 0f6509343c..b662396711 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/IPaasClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/IPaasClient.java @@ -54,6 +54,5 @@ public interface IPaasClient { /** * ESB发通知信息接口 */ - boolean sendMsg(String msgType, String sender, Set receivers, String title, String content) - throws Exception; + void sendMsg(String msgType, String sender, Set receivers, String title, String content); } diff --git a/src/backend/job-gateway/src/main/java/com/tencent/bk/job/gateway/web/service/impl/LoginServiceImpl.java b/src/backend/job-gateway/src/main/java/com/tencent/bk/job/gateway/web/service/impl/LoginServiceImpl.java index d3adcdf199..116db99e7a 100644 --- a/src/backend/job-gateway/src/main/java/com/tencent/bk/job/gateway/web/service/impl/LoginServiceImpl.java +++ b/src/backend/job-gateway/src/main/java/com/tencent/bk/job/gateway/web/service/impl/LoginServiceImpl.java @@ -106,7 +106,7 @@ public BkUserDTO getUser(String bkToken) { return userDto.orElse(null); } catch (ExecutionException e) { log.warn("Error occur when get user from paas!"); - throw new InternalException("Query userinfo from paas fail", e, ErrorCode.PAAS_API_DATA_ERROR); + throw new InternalException("Query userinfo from paas fail", e, ErrorCode.USER_MANAGE_API_ACCESS_ERROR); } } diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebGlobalSettingsResource.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebGlobalSettingsResource.java index 4c4aabd8ff..19105e77e2 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebGlobalSettingsResource.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebGlobalSettingsResource.java @@ -110,10 +110,10 @@ Response getChannelTemplateDetail( @RequestHeader("username") String username, @ApiParam("渠道Code") - @RequestParam(value = "channelCode", required = true) + @RequestParam(value = "channelCode") String channelCode, @ApiParam("消息类型Code") - @RequestParam(value = "messageTypeCode", required = true) + @RequestParam(value = "messageTypeCode") String messageTypeCode ); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceNotificationResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceNotificationResourceImpl.java index adebc1a633..c026f1597e 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceNotificationResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceNotificationResourceImpl.java @@ -58,7 +58,7 @@ public ServiceNotificationResourceImpl(NotifyService notifyService) { @Override public InternalResponse sendNotificationsToUsers(ServiceUserNotificationDTO serviceUserNotificationDTO) { log.info(String.format("Input:%s", JsonUtils.toJson(serviceUserNotificationDTO))); - return InternalResponse.buildSuccessResp(notifyService.sendNotificationsToUsers(serviceUserNotificationDTO)); + return InternalResponse.buildSuccessResp(notifyService.asyncSendNotificationsToUsers(serviceUserNotificationDTO)); } @Override @@ -67,7 +67,7 @@ public InternalResponse sendNotificationsToAdministrators( ) { log.info(String.format("Input:%s", JsonUtils.toJson(serviceNotificationMessage))); return InternalResponse.buildSuccessResp( - notifyService.sendNotificationsToAdministrators(serviceNotificationMessage) + notifyService.asyncSendNotificationsToAdministrators(serviceNotificationMessage) ); } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebGlobalSettingsResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebGlobalSettingsResourceImpl.java index ee5fb6764b..488f9e1546 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebGlobalSettingsResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebGlobalSettingsResourceImpl.java @@ -53,7 +53,7 @@ @Slf4j public class WebGlobalSettingsResourceImpl implements WebGlobalSettingsResource { - private GlobalSettingsService globalSettingsService; + private final GlobalSettingsService globalSettingsService; @Autowired public WebGlobalSettingsResourceImpl(GlobalSettingsService globalSettingsService) { diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/notify/impl/NotifyEsbChannelDAOImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/notify/impl/NotifyEsbChannelDAOImpl.java index aa69b80ee0..bb41e22346 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/notify/impl/NotifyEsbChannelDAOImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/notify/impl/NotifyEsbChannelDAOImpl.java @@ -96,7 +96,7 @@ public List listNotifyEsbChannel(DSLContext dslContext) { } catch (ExecutionException e) { String errorMsg = "Fail to load EsbChannel from cache"; logger.error(errorMsg, e); - throw new InternalException(errorMsg, e, ErrorCode.PAAS_MSG_CHANNEL_DATA_ERROR); + throw new InternalException(errorMsg, e, ErrorCode.CMSI_MSG_CHANNEL_DATA_ERROR); } } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/NotifyService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/NotifyService.java index a7dd1898a3..eb2fe3e108 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/NotifyService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/NotifyService.java @@ -95,12 +95,12 @@ Set findUserByResourceRoles(Long appId, String triggerUser, Integer reso PageTemplateVO getPageTemplate(String username); - Integer sendNotificationsToUsers(ServiceUserNotificationDTO serviceUserNotificationDTO); + Integer asyncSendNotificationsToUsers(ServiceUserNotificationDTO serviceUserNotificationDTO); - Integer sendNotificationsToUsersByChannel(ServiceUserNotificationDTO serviceUserNotificationDTO, - List channelTypeList); + Integer asyncSendNotificationsByChannel(ServiceUserNotificationDTO serviceUserNotificationDTO, + List channelTypeList); - Integer sendNotificationsToAdministrators(ServiceNotificationMessage serviceNotificationMessage); + Integer asyncSendNotificationsToAdministrators(ServiceNotificationMessage serviceNotificationMessage); Integer sendTemplateNotification(ServiceTemplateNotificationDTO templateNotificationDTO); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/PaaSService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/PaaSService.java index 765c18b559..bf3f6f3cae 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/PaaSService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/PaaSService.java @@ -40,11 +40,11 @@ public interface PaaSService { List getAllChannelList(String bkToken, String uin) throws IOException; - boolean sendMsg( + void sendMsg( String msgType, String sender, Set receivers, String title, String content - ) throws Exception; + ); } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/GlobalSettingsServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/GlobalSettingsServiceImpl.java index c42faa1828..15f1b0fda4 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/GlobalSettingsServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/GlobalSettingsServiceImpl.java @@ -55,8 +55,6 @@ import com.tencent.bk.job.manage.model.dto.notify.AvailableEsbChannelDTO; import com.tencent.bk.job.manage.model.dto.notify.NotifyEsbChannelDTO; import com.tencent.bk.job.manage.model.dto.notify.NotifyTemplateDTO; -import com.tencent.bk.job.manage.model.inner.ServiceNotificationMessage; -import com.tencent.bk.job.manage.model.inner.ServiceUserNotificationDTO; import com.tencent.bk.job.manage.model.web.request.globalsetting.AccountNameRule; import com.tencent.bk.job.manage.model.web.request.globalsetting.AccountNameRulesReq; import com.tencent.bk.job.manage.model.web.request.globalsetting.FileUploadSettingReq; @@ -80,6 +78,7 @@ import com.tencent.bk.job.manage.model.web.vo.notify.UserVO; import com.tencent.bk.job.manage.service.GlobalSettingsService; import com.tencent.bk.job.manage.service.NotifyService; +import com.tencent.bk.job.manage.service.impl.notify.NotifySendService; import com.tencent.bk.job.manage.service.impl.notify.NotifyUserService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -94,7 +93,6 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -121,6 +119,7 @@ public class GlobalSettingsServiceImpl implements GlobalSettingsService { private final NotifyEsbChannelDAO notifyEsbChannelDAO; private final AvailableEsbChannelDAO availableEsbChannelDAO; private final NotifyService notifyService; + private final NotifySendService notifySendService; private final NotifyUserService notifyUserService; private final GlobalSettingDAO globalSettingDAO; private final NotifyTemplateDAO notifyTemplateDAO; @@ -140,7 +139,8 @@ public GlobalSettingsServiceImpl( , NotifyEsbChannelDAO notifyEsbChannelDAO , AvailableEsbChannelDAO availableEsbChannelDAO , NotifyService notifyService - , NotifyUserService notifyUserService, + , NotifySendService notifySendService, + NotifyUserService notifyUserService, GlobalSettingDAO globalSettingDAO , NotifyTemplateDAO notifyTemplateDAO, MessageI18nService i18nService, @@ -152,6 +152,7 @@ public GlobalSettingsServiceImpl( this.notifyEsbChannelDAO = notifyEsbChannelDAO; this.availableEsbChannelDAO = availableEsbChannelDAO; this.notifyService = notifyService; + this.notifySendService = notifySendService; this.notifyUserService = notifyUserService; this.globalSettingDAO = globalSettingDAO; this.notifyTemplateDAO = notifyTemplateDAO; @@ -632,12 +633,15 @@ public Integer saveChannelTemplate(String username, ChannelTemplateReq req) { public Integer sendChannelTemplate(String username, ChannelTemplatePreviewReq req) { List receiverList = StringUtil.strToList(req.getReceiverStr(), String.class, NotifyConsts.SEPERATOR_COMMA); - return notifyService.sendNotificationsToUsersByChannel( - new ServiceUserNotificationDTO( - new HashSet<>(receiverList), - new ServiceNotificationMessage( - req.getTitle(), req.getContent())), - Collections.singletonList(req.getChannelCode())); + Set receiverSet = new HashSet<>(receiverList); + notifySendService.sendUserChannelNotify( + null, + receiverSet, + req.getChannelCode(), + req.getTitle(), + req.getContent() + ); + return receiverSet.size(); } @Override diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/PaaSServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/PaaSServiceImpl.java index 0c6d54a18b..f36fabc004 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/PaaSServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/PaaSServiceImpl.java @@ -86,14 +86,14 @@ public List getAllChannelList(String bkToken, String uin) { @Override @EsbApiTimed - public boolean sendMsg( + public void sendMsg( String msgType, String sender, Set receivers, String title, String content - ) throws Exception { + ) { IPaasClient paasClient = getClientWithCurrentLang(); - return paasClient.sendMsg(msgType, sender, receivers, title, content); + paasClient.sendMsg(msgType, sender, receivers, title, content); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/WatchableSendMsgService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/WatchableSendMsgService.java index 08b7c1a176..0bc97942a2 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/WatchableSendMsgService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/WatchableSendMsgService.java @@ -54,7 +54,7 @@ public WatchableSendMsgService(PaaSService paaSService, } @EsbApiTimed - public boolean sendMsg( + public void sendMsg( Long appId, long createTimeMillis, String msgType, @@ -62,14 +62,11 @@ public boolean sendMsg( Set receivers, String title, String content - ) throws Exception { + ) { String sendStatus = MetricsConstants.TAG_VALUE_SEND_STATUS_FAILED; try { - boolean result = paaSService.sendMsg(msgType, sender, receivers, title, content); - if (result) { - sendStatus = MetricsConstants.TAG_VALUE_SEND_STATUS_SUCCESS; - } - return result; + paaSService.sendMsg(msgType, sender, receivers, title, content); + sendStatus = MetricsConstants.TAG_VALUE_SEND_STATUS_SUCCESS; } finally { long delayMillis = System.currentTimeMillis() - createTimeMillis; Tags tags = Tags.of(MetricsConstants.TAG_KEY_MSG_TYPE, msgType); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java index 2ef3bd28d7..5a2ce1072c 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java @@ -33,6 +33,8 @@ import io.micrometer.core.instrument.Tag; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.helpers.FormattingTuple; +import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -112,7 +114,8 @@ private SendNotifyTask buildSendTask(Long appId, return task; } - public void sendUserChannelNotify(Long appId, Set receivers, String channel, String title, String content) { + public void asyncSendUserChannelNotify(Long appId, Set receivers, String channel, String title, + String content) { if (CollectionUtils.isEmpty(receivers)) { log.warn("receivers is empty of channel {}, do not send notification", channel); return; @@ -127,7 +130,34 @@ public void sendUserChannelNotify(Long appId, Set receivers, String chan notifySendExecutor.submit(buildSendTask(appId, receivers, channel, title, content)); } - public void sendNotifyMessages(Long appId, Map> channelUsersMap, String title, String content) { - channelUsersMap.forEach((channel, userSet) -> sendUserChannelNotify(appId, userSet, channel, title, content)); + public void sendUserChannelNotify(Long appId, + Set receivers, + String channel, + String title, + String content) { + if (CollectionUtils.isEmpty(receivers)) { + FormattingTuple msg = MessageFormatter.format( + "receivers is empty of channel {}, do not send notification", + channel + ); + log.warn(msg.getMessage()); + return; + } + watchableSendMsgService.sendMsg( + appId, + System.currentTimeMillis(), + channel, + null, + receivers, + title, + content + ); + } + + public void asyncSendNotifyMessages(Long appId, Map> channelUsersMap, String title, + String content) { + channelUsersMap.forEach((channel, userSet) -> + asyncSendUserChannelNotify(appId, userSet, channel, title, content) + ); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java index 6cc3e60a1b..9f7e08bad4 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java @@ -418,7 +418,7 @@ public Integer sendSimpleNotification(ServiceNotificationDTO notification) { } ServiceNotificationMessage notificationMessage = notifyMessageMap.get(new ArrayList<>(notifyMessageMap.keySet()).get(0)); - notifySendService.sendNotifyMessages( + notifySendService.asyncSendNotifyMessages( notification.getTriggerDTO().getAppId(), channelUsersMap, notificationMessage.getTitle(), @@ -635,22 +635,22 @@ public PageTemplateVO getPageTemplate(String username) { } @Override - public Integer sendNotificationsToUsers(ServiceUserNotificationDTO serviceUserNotificationDTO) { + public Integer asyncSendNotificationsToUsers(ServiceUserNotificationDTO serviceUserNotificationDTO) { // 获取所有可用渠道 List availableChannelTypeList = getAvailableChannelTypeList(); - return sendNotificationsToUsersByChannel(serviceUserNotificationDTO, availableChannelTypeList); + return asyncSendNotificationsByChannel(serviceUserNotificationDTO, availableChannelTypeList); } @Override - public Integer sendNotificationsToUsersByChannel(ServiceUserNotificationDTO serviceUserNotificationDTO, - List channelTypeList) { + public Integer asyncSendNotificationsByChannel(ServiceUserNotificationDTO serviceUserNotificationDTO, + List channelTypeList) { // 组装通知map Map> channelUsersMap = new HashMap<>(); for (String channelType : channelTypeList) { channelUsersMap.put(channelType, serviceUserNotificationDTO.getReceivers()); } ServiceNotificationMessage notificationMessage = serviceUserNotificationDTO.getNotificationMessage(); - notifySendService.sendNotifyMessages( + notifySendService.asyncSendNotifyMessages( null, channelUsersMap, notificationMessage.getTitle(), @@ -660,9 +660,9 @@ public Integer sendNotificationsToUsersByChannel(ServiceUserNotificationDTO serv } @Override - public Integer sendNotificationsToAdministrators(ServiceNotificationMessage serviceNotificationMessage) { + public Integer asyncSendNotificationsToAdministrators(ServiceNotificationMessage serviceNotificationMessage) { List administrators = localPermissionService.getAdministrators(); - return sendNotificationsToUsers(new ServiceUserNotificationDTO(new HashSet<>(administrators), + return asyncSendNotificationsToUsers(new ServiceUserNotificationDTO(new HashSet<>(administrators), serviceNotificationMessage)); } @@ -714,7 +714,7 @@ public Integer sendTemplateNotification(ServiceTemplateNotificationDTO templateN ); //发送消息通知 if (notifyMsg != null) { - notifySendService.sendUserChannelNotify( + notifySendService.asyncSendUserChannelNotify( appId, userSet, channel, @@ -771,7 +771,7 @@ public Integer triggerTemplateNotification(ServiceTriggerTemplateNotificationDTO log.warn(PrefConsts.TAG_PREF_SLOW + watch.prettyPrint()); } if (notificationMessage != null) { - notifySendService.sendUserChannelNotify( + notifySendService.asyncSendUserChannelNotify( appId, userSet, channel, diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java index 1d9d3fd549..d29508f25b 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java @@ -67,8 +67,8 @@ public void run() { return; } try { - boolean sendResult = sendMsgWithRetry(); - if (sendResult) { + boolean result = sendMsgWithRetry(); + if (result) { logSendSuccess(); } else { handleSendFail(null); @@ -82,22 +82,27 @@ private void logInvalidReceivers() { log.warn("receivers is null or empty, skip, msgType={},title={}", msgType, title); } - private boolean sendMsgWithRetry() throws Exception { + private boolean sendMsgWithRetry() { int count = 0; - boolean sendResult = false; - while (!sendResult && count < NOTIFY_MAX_RETRY_COUNT) { + boolean result = false; + while (!result && count < NOTIFY_MAX_RETRY_COUNT) { count += 1; - sendResult = watchableSendMsgService.sendMsg( - appId, - createTimeMillis, - msgType, - sender, - receivers, - title, - content - ); + try { + watchableSendMsgService.sendMsg( + appId, + createTimeMillis, + msgType, + sender, + receivers, + title, + content + ); + result = true; + } catch (Exception e) { + log.warn("Fail to sendMsg", e); + } } - return sendResult; + return result; } private void logSendSuccess() { From 8e83e74a958f4a820ad7f200fae0bc98b388b4db Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 15:22:03 +0800 Subject: [PATCH 2/7] =?UTF-8?q?bugfix:=20=E5=85=A8=E5=B1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E9=A2=84=E8=A7=88=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E4=BB=8D=E6=8F=90=E7=A4=BA=E5=8F=91=E9=80=81=E6=88=90=E5=8A=9F?= =?UTF-8?q?=20#1225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化报错信息 --- .../src/main/resources/i18n/exception/message.properties | 2 +- .../src/main/resources/i18n/exception/message_en.properties | 2 +- .../main/resources/i18n/exception/message_en_US.properties | 2 +- .../src/main/resources/i18n/exception/message_zh.properties | 2 +- .../main/resources/i18n/exception/message_zh_CN.properties | 2 +- .../java/com/tencent/bk/job/common/constant/ErrorCode.java | 2 +- .../com/tencent/bk/job/common/paas/user/EEPaasClient.java | 3 +++ .../bk/job/manage/service/impl/notify/SendNotifyTask.java | 4 ++-- 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties index 15111d92ee..741d4248f3 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message.properties @@ -75,7 +75,7 @@ 1213001=CMSI接口访问异常 1213002=用户管理接口访问异常 1213003=调用CMSI接口获取通知渠道数据异常 -1213004=调用CMSI接口发送通知失败,原因:{0} +1213004=调用CMSI接口发送通知失败,错误码:{0},错误信息:{1} 1214001=ARTIFACTORY API返回数据异常 1214002=制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties index 973da5d935..17a83048ce 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en.properties @@ -75,7 +75,7 @@ 1213001=Fail to request CMSI API 1213002=Fail to request UserManage API 1213003=CMSI exception when get notify channels -1213004=CMSI exception when send notify, reason:{0} +1213004=CMSI exception when send notify, error_code={0}, error_msg={1} 1214001=ARTIFACTORY API returned data exception 1214002=Cannot find node in bkrepo:{0}, please check in bkrepo diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties index 973da5d935..17a83048ce 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_en_US.properties @@ -75,7 +75,7 @@ 1213001=Fail to request CMSI API 1213002=Fail to request UserManage API 1213003=CMSI exception when get notify channels -1213004=CMSI exception when send notify, reason:{0} +1213004=CMSI exception when send notify, error_code={0}, error_msg={1} 1214001=ARTIFACTORY API returned data exception 1214002=Cannot find node in bkrepo:{0}, please check in bkrepo diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties index 15111d92ee..741d4248f3 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh.properties @@ -75,7 +75,7 @@ 1213001=CMSI接口访问异常 1213002=用户管理接口访问异常 1213003=调用CMSI接口获取通知渠道数据异常 -1213004=调用CMSI接口发送通知失败,原因:{0} +1213004=调用CMSI接口发送通知失败,错误码:{0},错误信息:{1} 1214001=ARTIFACTORY API返回数据异常 1214002=制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties index 15111d92ee..741d4248f3 100644 --- a/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties +++ b/src/backend/commons/common-i18n/src/main/resources/i18n/exception/message_zh_CN.properties @@ -75,7 +75,7 @@ 1213001=CMSI接口访问异常 1213002=用户管理接口访问异常 1213003=调用CMSI接口获取通知渠道数据异常 -1213004=调用CMSI接口发送通知失败,原因:{0} +1213004=调用CMSI接口发送通知失败,错误码:{0},错误信息:{1} 1214001=ARTIFACTORY API返回数据异常 1214002=制品库中找不到节点:{0},请到制品库核实 diff --git a/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java b/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java index 2c3aa1691a..a0559b4179 100644 --- a/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java +++ b/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/constant/ErrorCode.java @@ -394,7 +394,7 @@ public class ErrorCode { public static final int USER_MANAGE_API_ACCESS_ERROR = 1213002; // 调用CMSI接口获取通知渠道数据异常 public static final int CMSI_MSG_CHANNEL_DATA_ERROR = 1213003; - // 调用CMSI接口发送通知失败,原因:{0} + // 调用CMSI接口发送通知失败,错误码:{0},错误信息:{1} public static final int CMSI_FAIL_TO_SEND_MSG = 1213004; // 制品库异常 diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java index 7cdf5f8018..cef2836c8c 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java @@ -200,10 +200,13 @@ public void sendMsg( ErrorType.FAILED_PRECONDITION, ErrorCode.CMSI_FAIL_TO_SEND_MSG, new Object[]{ + esbResp.getCode(), esbResp.getMessage() }); } status = EsbMetricTags.VALUE_STATUS_SUCCESS; + } catch (PaasException e) { + throw e; } catch (Exception e) { log.error("Fail to request {}", uri, e); status = EsbMetricTags.VALUE_STATUS_ERROR; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java index d29508f25b..b629f6b159 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java @@ -116,9 +116,9 @@ private void handleSendFail(Exception e) { logIgnoreToSend(); return; } - FormattingTuple msg = MessageFormatter.format( + FormattingTuple msg = MessageFormatter.arrayFormat( "Fail to send notify:({},{},{},{})", - new String[]{ + new Object[]{ String.join(",", receivers), msgType, title, From 3f529f9dcf14fbc02e2a8b56e9c169dc5c164f76 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 16:08:30 +0800 Subject: [PATCH 3/7] =?UTF-8?q?bugfix:=20=E5=85=A8=E5=B1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E9=A2=84=E8=A7=88=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E4=BB=8D=E6=8F=90=E7=A4=BA=E5=8F=91=E9=80=81=E6=88=90=E5=8A=9F?= =?UTF-8?q?=20#1225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化报错信息 --- .../java/com/tencent/bk/job/common/paas/user/EEPaasClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java index cef2836c8c..6a2c97fede 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java @@ -200,7 +200,7 @@ public void sendMsg( ErrorType.FAILED_PRECONDITION, ErrorCode.CMSI_FAIL_TO_SEND_MSG, new Object[]{ - esbResp.getCode(), + esbResp.getCode().toString(), esbResp.getMessage() }); } From 018f41ec851ca2e84fe546e26cd6f2d4fa715d57 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 16:10:02 +0800 Subject: [PATCH 4/7] =?UTF-8?q?bugfix:=20=E5=85=A8=E5=B1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E9=A2=84=E8=A7=88=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E4=BB=8D=E6=8F=90=E7=A4=BA=E5=8F=91=E9=80=81=E6=88=90=E5=8A=9F?= =?UTF-8?q?=20#1225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新版本号 --- .../kubernetes/charts/bk-job/Chart.yaml | 4 ++-- .../kubernetes/charts/bk-job/values.yaml | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/support-files/kubernetes/charts/bk-job/Chart.yaml b/support-files/kubernetes/charts/bk-job/Chart.yaml index 7be5fda32f..8015d05166 100644 --- a/support-files/kubernetes/charts/bk-job/Chart.yaml +++ b/support-files/kubernetes/charts/bk-job/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: "bk-job" description: The BK-JOB is a ops script management and execution system with the capability of dealing with multiple tasks simultaneously. type: application -version: 0.2.5-rc.24 -appVersion: "3.5.0-rc.24" +version: 0.2.5-rc.25 +appVersion: "3.5.0-rc.25" dependencies: - name: common diff --git a/support-files/kubernetes/charts/bk-job/values.yaml b/support-files/kubernetes/charts/bk-job/values.yaml index c44e51ffb0..67e32297dd 100644 --- a/support-files/kubernetes/charts/bk-job/values.yaml +++ b/support-files/kubernetes/charts/bk-job/values.yaml @@ -647,7 +647,7 @@ gatewayConfig: image: registry: hub.bktencent.com repository: blueking/job-gateway - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -735,7 +735,7 @@ manageConfig: image: registry: hub.bktencent.com repository: blueking/job-manage - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -793,7 +793,7 @@ executeConfig: image: registry: hub.bktencent.com repository: blueking/job-execute - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -844,7 +844,7 @@ crontabConfig: image: registry: hub.bktencent.com repository: blueking/job-crontab - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -904,7 +904,7 @@ logsvrConfig: image: registry: hub.bktencent.com repository: blueking/job-logsvr - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -959,7 +959,7 @@ backupConfig: image: registry: hub.bktencent.com repository: blueking/job-backup - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -1009,7 +1009,7 @@ analysisConfig: image: registry: hub.bktencent.com repository: blueking/job-analysis - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -1059,7 +1059,7 @@ fileGatewayConfig: image: registry: hub.bktencent.com repository: blueking/job-file-gateway - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -1109,7 +1109,7 @@ fileWorkerConfig: image: registry: hub.bktencent.com repository: blueking/job-file-worker - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -1182,7 +1182,7 @@ frontendConfig: image: registry: hub.bktencent.com repository: blueking/job-frontend - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 pullPolicy: IfNotPresent pullSecrets: [] replicaCount: 1 @@ -1243,7 +1243,7 @@ migration: # 镜像拉取仓库组织与镜像名称 repository: "blueking/job-migration" # 镜像标签 - tag: 3.5.0-rc.24 + tag: 3.5.0-rc.25 # 镜像拉取策略 pullPolicy: IfNotPresent From 979dea676b72901cda4dc974e3b3f200420e2e75 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 18:02:02 +0800 Subject: [PATCH 5/7] =?UTF-8?q?bugfix:=20=E5=85=A8=E5=B1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E9=A2=84=E8=A7=88=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E4=BB=8D=E6=8F=90=E7=A4=BA=E5=8F=91=E9=80=81=E6=88=90=E5=8A=9F?= =?UTF-8?q?=20#1225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 代码优化 --- .../com/tencent/bk/job/common/paas/user/EEPaasClient.java | 2 +- .../job/manage/service/impl/notify/NotifySendService.java | 8 +------- .../bk/job/manage/service/impl/notify/SendNotifyTask.java | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java index 6a2c97fede..b63666ea48 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java @@ -197,7 +197,7 @@ public void sendMsg( if (esbResp.getResult() == null || !esbResp.getResult() || esbResp.getCode() != 0) { status = checkRespAndGetStatus(uri, esbResp); throw new PaasException( - ErrorType.FAILED_PRECONDITION, + ErrorType.INTERNAL, ErrorCode.CMSI_FAIL_TO_SEND_MSG, new Object[]{ esbResp.getCode().toString(), diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java index 5a2ce1072c..1615ca368d 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifySendService.java @@ -33,8 +33,6 @@ import io.micrometer.core.instrument.Tag; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; -import org.slf4j.helpers.FormattingTuple; -import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -136,11 +134,7 @@ public void sendUserChannelNotify(Long appId, String title, String content) { if (CollectionUtils.isEmpty(receivers)) { - FormattingTuple msg = MessageFormatter.format( - "receivers is empty of channel {}, do not send notification", - channel - ); - log.warn(msg.getMessage()); + log.warn("receivers is empty of channel {}, do not send notification", channel); return; } watchableSendMsgService.sendMsg( diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java index b629f6b159..1409cb46da 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/SendNotifyTask.java @@ -99,7 +99,7 @@ private boolean sendMsgWithRetry() { ); result = true; } catch (Exception e) { - log.warn("Fail to sendMsg", e); + log.error("Fail to sendMsg", e); } } return result; From c975b29077143490a3a1950f1f254d544734731c Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 18:07:44 +0800 Subject: [PATCH 6/7] =?UTF-8?q?bugfix:=20=E9=BB=98=E8=AE=A4=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=AD=96=E7=95=A5=E4=B8=8B=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5=E4=B8=8D=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20#1262?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk/job/manage/service/impl/notify/NotifyServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java index 9f7e08bad4..4e69223252 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/notify/NotifyServiceImpl.java @@ -552,7 +552,7 @@ private List getTriggerPolicys(Long appId, // 3.默认业务 // 业务未配置消息通知策略才使用默认策略 if (!appNotifyPolicyConfigured(appId) && CollectionUtils.isEmpty(triggerPolicyList)) { - triggerPolicyList = systemDefaultNotifyPolices(resourceType, triggerType, resourceExecuteStatus); + triggerPolicyList = systemDefaultNotifyPolices(triggerType, resourceType, resourceExecuteStatus); } return triggerPolicyList; } From a5e87410f21be74728930fc1638839aaeb6ccc55 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Wed, 7 Sep 2022 18:11:17 +0800 Subject: [PATCH 7/7] =?UTF-8?q?bugfix:=20=E5=85=A8=E5=B1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B6=88=E6=81=AF=E9=A2=84=E8=A7=88=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E4=BB=8D=E6=8F=90=E7=A4=BA=E5=8F=91=E9=80=81=E6=88=90=E5=8A=9F?= =?UTF-8?q?=20#1225?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 代码优化 --- .../java/com/tencent/bk/job/common/paas/user/EEPaasClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java index b63666ea48..b848c0f122 100644 --- a/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java +++ b/src/backend/commons/paas-sdk/src/main/java/com/tencent/bk/job/common/paas/user/EEPaasClient.java @@ -210,7 +210,7 @@ public void sendMsg( } catch (Exception e) { log.error("Fail to request {}", uri, e); status = EsbMetricTags.VALUE_STATUS_ERROR; - throw new PaasException(e, ErrorType.FAILED_PRECONDITION, ErrorCode.CMSI_API_ACCESS_ERROR, new Object[]{}); + throw new PaasException(e, ErrorType.INTERNAL, ErrorCode.CMSI_API_ACCESS_ERROR, new Object[]{}); } finally { HttpMetricUtil.clearHttpMetric(); recordMetrics(start, status, msgType);