diff --git a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamAppTransferAspect.java b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamAppTransferAspect.java index c7e0371b41..a5be08ab2b 100644 --- a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamAppTransferAspect.java +++ b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamAppTransferAspect.java @@ -24,15 +24,18 @@ public IamAppTransferAspect(AppScopeMappingService appScopeMappingService) { this.appScopeMappingService = appScopeMappingService; } - @Pointcut("execution (* com.tencent.bk.job.common.iam.service.impl.BusinessAuthServiceImpl.auth*(..))") + @Pointcut("within(com.tencent.bk.job.common.iam.service.impl.BusinessAuthServiceImpl) " + + "&& execution (* com.tencent.bk.job.common.iam.service.impl.BusinessAuthServiceImpl.auth*(..))") public void processAuthBusinessAction() { } - @Pointcut("execution (* com.tencent.bk.job.*.auth..impl.*.auth*(..))") + @Pointcut("within(com.tencent.bk.job..*) " + + "&& execution (* com.tencent.bk.job.*.auth..impl.*.auth*(..))") public void processAuthResourceAction() { } - @Pointcut("execution (* com.tencent.bk.job.*.auth..impl.*.batchAuth*(..))") + @Pointcut("within(com.tencent.bk.job..*) " + + "&& execution (* com.tencent.bk.job.*.auth..impl.*.batchAuth*(..))") public void processBatchAuthResourceAction() { } diff --git a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java index 1ed0279e5a..fef1c67f9f 100644 --- a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java +++ b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java @@ -15,7 +15,7 @@ public class IamCallbackAspect { public IamCallbackAspect() { } - @Pointcut("execution (* com.tencent.bk.job.*.api.iam.impl.*.callback(..))") + @Pointcut("within(com.tencent.bk.job..*) && execution (* com.tencent.bk.job.*.api.iam.impl.*.callback(..))") public void processCallbackRequest() { } diff --git a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamExceptionHandleAspect.java b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamExceptionHandleAspect.java index 758e50adac..2fce0bd86b 100644 --- a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamExceptionHandleAspect.java +++ b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamExceptionHandleAspect.java @@ -17,11 +17,13 @@ @Aspect public class IamExceptionHandleAspect { - @Pointcut("execution (* com.tencent.bk.sdk.iam.service.impl.PolicyServiceImpl.*(..))") + @Pointcut("within(com.tencent.bk.sdk.iam.service.impl.PolicyServiceImpl) " + + "&& execution (* com.tencent.bk.sdk.iam.service.impl.PolicyServiceImpl.*(..))") public void processPolicyServiceAction() { } - @Pointcut("execution (* com.tencent.bk.sdk.iam.helper.AuthHelper.isAllowed(..))") + @Pointcut("within(com.tencent.bk.sdk.iam.helper.AuthHelper) " + + "&& execution (* com.tencent.bk.sdk.iam.helper.AuthHelper.isAllowed(..))") public void processIsAllowedAction() { } diff --git a/src/backend/commons/common-mysql/src/main/java/com/tencent/bk/job/common/mysql/config/JobMySQLAutoConfiguration.java b/src/backend/commons/common-mysql/src/main/java/com/tencent/bk/job/common/mysql/JobTransactional.java similarity index 70% rename from src/backend/commons/common-mysql/src/main/java/com/tencent/bk/job/common/mysql/config/JobMySQLAutoConfiguration.java rename to src/backend/commons/common-mysql/src/main/java/com/tencent/bk/job/common/mysql/JobTransactional.java index 84ce6a243f..93a177417d 100644 --- a/src/backend/commons/common-mysql/src/main/java/com/tencent/bk/job/common/mysql/config/JobMySQLAutoConfiguration.java +++ b/src/backend/commons/common-mysql/src/main/java/com/tencent/bk/job/common/mysql/JobTransactional.java @@ -22,18 +22,23 @@ * IN THE SOFTWARE. */ -package com.tencent.bk.job.common.mysql.config; +package com.tencent.bk.job.common.mysql; -import org.jooq.DSLContext; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.AliasFor; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Transactional; -import javax.sql.DataSource; +/** + * Job 自定义事务注解 + */ +@Transactional +public @interface JobTransactional { + @AliasFor(annotation = Transactional.class) + String transactionManager(); -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass(DSLContext.class) -@ConditionalOnBean(DataSource.class) -public class JobMySQLAutoConfiguration { + @AliasFor(annotation = Transactional.class) + Class[] rollbackFor() default {Throwable.class}; + @AliasFor(annotation = Transactional.class) + int timeout() default TransactionDefinition.TIMEOUT_DEFAULT; } diff --git a/src/backend/commons/common-mysql/src/main/resources/META-INF/spring.factories b/src/backend/commons/common-mysql/src/main/resources/META-INF/spring.factories deleted file mode 100644 index a4c653a47a..0000000000 --- a/src/backend/commons/common-mysql/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.tencent.bk.job.common.mysql.config.JobMySQLAutoConfiguration diff --git a/src/backend/commons/common-web/src/main/java/com/tencent/bk/job/common/web/aspects/EsbAppResourceScopeReqAspect.java b/src/backend/commons/common-web/src/main/java/com/tencent/bk/job/common/web/aspects/EsbAppResourceScopeReqAspect.java index 5348ed92af..bd40a0a1bb 100644 --- a/src/backend/commons/common-web/src/main/java/com/tencent/bk/job/common/web/aspects/EsbAppResourceScopeReqAspect.java +++ b/src/backend/commons/common-web/src/main/java/com/tencent/bk/job/common/web/aspects/EsbAppResourceScopeReqAspect.java @@ -43,7 +43,7 @@ public EsbAppResourceScopeReqAspect(AppScopeMappingService appScopeMappingServic this.appScopeMappingService = appScopeMappingService; } - @Before("execution(* com.tencent.bk.job.*.api.esb..*.*(..)))") + @Before("within(com.tencent.bk.job..*) && execution(* com.tencent.bk.job.*.api.esb..*.*(..)))") public void handleAppScopeReq(JoinPoint joinPoint) { Object[] args = joinPoint.getArgs(); for (Object arg : args) { diff --git a/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/VersionInfoLogApplicationRunner.java b/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/VersionInfoLogApplicationRunner.java new file mode 100644 index 0000000000..9c24d0b66c --- /dev/null +++ b/src/backend/commons/common/src/main/java/com/tencent/bk/job/common/VersionInfoLogApplicationRunner.java @@ -0,0 +1,54 @@ +/* + * + * * 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; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.boot.info.BuildProperties; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class VersionInfoLogApplicationRunner implements ApplicationRunner { + @Value("${spring.application.name:bk-job}") + private String serviceName; + private final BuildProperties buildProperties; + + @Autowired + public VersionInfoLogApplicationRunner(BuildProperties buildProperties) { + this.buildProperties = buildProperties; + } + + @Override + public void run(ApplicationArguments args){ + String version = buildProperties.getVersion(); + log.info("Service name: '{}', Version: '{}'", serviceName, version); + } +} diff --git a/src/backend/commons/esb-sdk/src/main/java/com/tencent/bk/job/common/esb/metrics/EsbApiTimedAspect.java b/src/backend/commons/esb-sdk/src/main/java/com/tencent/bk/job/common/esb/metrics/EsbApiTimedAspect.java index 156bd6b8ba..bbb3f8a96c 100644 --- a/src/backend/commons/esb-sdk/src/main/java/com/tencent/bk/job/common/esb/metrics/EsbApiTimedAspect.java +++ b/src/backend/commons/esb-sdk/src/main/java/com/tencent/bk/job/common/esb/metrics/EsbApiTimedAspect.java @@ -63,7 +63,7 @@ public static Tag exception(Throwable exception) { return EXCEPTION_NONE; } - @Around("execution (@com.tencent.bk.job.common.esb.metrics.EsbApiTimed * *.*(..))") + @Around("within(com.tencent.bk.job..*) && execution (@com.tencent.bk.job.common.esb.metrics.EsbApiTimed * *.*(..))") public Object timedMethod(ProceedingJoinPoint pjp) throws Throwable { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); HttpServletRequest request = null; diff --git a/src/backend/job-crontab/service-job-crontab/build.gradle b/src/backend/job-crontab/service-job-crontab/build.gradle index d76a4fe324..edede030db 100644 --- a/src/backend/job-crontab/service-job-crontab/build.gradle +++ b/src/backend/job-crontab/service-job-crontab/build.gradle @@ -28,6 +28,7 @@ dependencies { api project(":commons:common-redis") api project(":commons:common-web") api project(':commons:common-security') + api project(':commons:common-mysql') api project(":job-execute:api-job-execute") api project(":job-manage:api-job-manage") api project(":job-crontab:api-job-crontab") diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/inner/impl/ServiceCronJobResourceImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/inner/impl/ServiceCronJobResourceImpl.java index c25381fd65..635aa24855 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/inner/impl/ServiceCronJobResourceImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/inner/impl/ServiceCronJobResourceImpl.java @@ -28,6 +28,7 @@ import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.InternalResponse; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.date.DateUtils; import com.tencent.bk.job.common.util.json.JsonUtils; @@ -43,7 +44,6 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; @@ -116,7 +116,7 @@ public InternalResponse>> batchListCronJobByPlanIds(Lo } @Override - @Transactional(value = "jobCrontabTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobCrontabTransactionManager") public InternalResponse saveCronJobWithId(String username, Long appId, Long cronJobId, Long createTime, Long lastModifyTime, String lastModifyUser, CronJobCreateUpdateReq cronJobCreateUpdateReq) { diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobBatchLoadServiceImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobBatchLoadServiceImpl.java index 56651c45e1..6b06290653 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobBatchLoadServiceImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobBatchLoadServiceImpl.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.crontab.service.impl; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.crontab.model.dto.CronJobBasicInfoDTO; import com.tencent.bk.job.crontab.service.CronJobBatchLoadService; import com.tencent.bk.job.crontab.service.CronJobService; @@ -31,7 +32,6 @@ import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -48,7 +48,7 @@ public CronJobBatchLoadServiceImpl(CronJobService cronJobService) { } @Override - @Transactional(rollbackFor = {Exception.class, Error.class}, timeout = 30) + @JobTransactional(transactionManager = "jobCrontabTransactionManager", timeout = 30) public CronLoadResult batchLoadCronToQuartz(int start, int limit) { int successNum = 0; int failedNum = 0; diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java index fbb5c3c680..f2a302b02c 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java @@ -42,6 +42,7 @@ import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.common.model.dto.AppResourceScope; import com.tencent.bk.job.common.model.dto.HostDTO; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.date.DateUtils; import com.tencent.bk.job.common.util.json.JsonUtils; @@ -84,7 +85,6 @@ import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.sql.Date; import java.time.Instant; @@ -200,7 +200,7 @@ public boolean updateCronJobErrorById(CronJobInfoDTO cronJobErrorInfo) { } @Override - @Transactional(value = "jobCrontabTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobCrontabTransactionManager") @ActionAuditRecord( actionId = ActionId.CREATE_CRON, instance = @AuditInstanceRecord( @@ -227,7 +227,7 @@ public CronJobInfoDTO createCronJobInfo(String username, CronJobInfoDTO cronJobI } @Override - @Transactional(rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobCrontabTransactionManager") @ActionAuditRecord( actionId = ActionId.MANAGE_CRON, instance = @AuditInstanceRecord( @@ -393,7 +393,7 @@ public Boolean deleteCronJobInfo(String username, Long appId, Long cronJobId) { } @Override - @Transactional(value = "jobCrontabTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobCrontabTransactionManager") @ActionAuditRecord( actionId = ActionId.MANAGE_CRON, instance = @AuditInstanceRecord( @@ -452,7 +452,7 @@ public Boolean changeCronJobEnableStatus(String username, Long appId, Long cronJ } @Override - @Transactional(value = "jobCrontabTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobCrontabTransactionManager") public Boolean disableExpiredCronJob(Long appId, Long cronJobId, String lastModifyUser, Long lastModifyTime) { CronJobInfoDTO cronJobInfo = new CronJobInfoDTO(); cronJobInfo.setAppId(appId); @@ -508,7 +508,7 @@ public Map> listCronJobByPlanIds(Long appId, List logs = scriptLogs.stream() - .map(scriptLog -> buildServiceExecuteObjectLogDTO(stepInstanceId, executeCount, batch, scriptLog)) - .collect(Collectors.toList()); - request.setLogs(logs); + + List logs = new ArrayList<>(); + int accumulatedSize = 0; + + for (ServiceExecuteObjectScriptLogDTO scriptLog : scriptLogs) { + ServiceExecuteObjectLogDTO executeObjectLog = + buildServiceExecuteObjectLogDTO(stepInstanceId, executeCount, batch, scriptLog); + logs.add(executeObjectLog); + accumulatedSize += scriptLog.getContentSizeBytes(); + ; + if (accumulatedSize > requestContentSizeThreshold) { + // 当达到阈值,保存当前积累的logs集合 + request.setLogs(logs); + saveLogs(request, stepInstanceId, executeCount, batch); + logs.clear(); + accumulatedSize = 0; + if (log.isDebugEnabled()) { + log.debug("The current script log is too large, exceeding {}, and should be saved in batches, " + + "stepInstanceId:{}, executeCount:{}, batch: {}", + requestContentSizeThreshold, stepInstanceId, executeCount, batch); + } + } + } + + if (!logs.isEmpty()) { + request.setLogs(logs); + saveLogs(request, stepInstanceId, executeCount, batch); + } + } + + private void saveLogs(ServiceBatchSaveLogRequest request, + long stepInstanceId, + int executeCount, + Integer batch) { InternalResponse resp = logResource.saveLogs(request); if (!resp.isSuccess()) { log.error("Batch write log content fail, stepInstanceId:{}, executeCount:{}, batch: {}", diff --git a/src/backend/job-file-gateway/service-job-file-gateway/build.gradle b/src/backend/job-file-gateway/service-job-file-gateway/build.gradle index 1c6b7860ee..b4722484af 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/build.gradle +++ b/src/backend/job-file-gateway/service-job-file-gateway/build.gradle @@ -25,6 +25,7 @@ dependencies { api project(":commons:common-web") api project(":commons:common-redis") + api project(":commons:common-mysql") api project(":job-manage:api-job-manage") api project(":job-file-worker-sdk:api-job-file-worker-sdk") api project(":job-file-gateway:api-job-file-gateway") diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskServiceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskServiceImpl.java index 54b20f20b0..50aaf4664a 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskServiceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskServiceImpl.java @@ -30,6 +30,7 @@ import com.tencent.bk.job.common.exception.ServiceException; import com.tencent.bk.job.common.model.Response; import com.tencent.bk.job.common.model.http.HttpReq; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.http.JobHttpClient; import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.file_gateway.consts.TaskCommandEnum; @@ -56,7 +57,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; @@ -110,7 +110,7 @@ public TaskInfoDTO startFileSourceDownloadTask(String username, Long appId, Long fileSourceId, filePathList, null); } - @Transactional(value = "jobFileGatewayTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobFileGatewayTransactionManager") public TaskInfoDTO startFileSourceDownloadTaskWithId(String username, Long appId, Long stepInstanceId, Integer executeCount, String batchTaskId, Integer fileSourceId, List filePathList, diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskUpdateServiceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskUpdateServiceImpl.java index 0b0e315443..cd9d8de360 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskUpdateServiceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceTaskUpdateServiceImpl.java @@ -26,6 +26,7 @@ import com.tencent.bk.job.common.constant.ErrorCode; import com.tencent.bk.job.common.exception.NotFoundException; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.ArrayUtil; import com.tencent.bk.job.common.util.file.FileSizeUtil; import com.tencent.bk.job.common.util.file.PathUtil; @@ -53,7 +54,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Date; @@ -95,7 +95,7 @@ public void addFileTaskStatusChangeListener(FileTaskStatusChangeListener listene } @Override - @Transactional(value = "jobFileGatewayTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobFileGatewayTransactionManager") public String updateFileSourceTask(String batchTaskId, String fileSourceTaskId, Long fileTaskId, diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileWorkerServiceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileWorkerServiceImpl.java index 0dbb7c72c0..65955388a6 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileWorkerServiceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileWorkerServiceImpl.java @@ -25,6 +25,7 @@ package com.tencent.bk.job.file_gateway.service.impl; import com.fasterxml.jackson.core.type.TypeReference; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.file_gateway.config.FileGatewayConfig; import com.tencent.bk.job.file_gateway.consts.WorkerSelectScopeEnum; @@ -41,7 +42,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; @@ -71,7 +71,7 @@ public FileWorkerServiceImpl(FileWorkerDAO fileWorkerDAO, } @Override - @Transactional(value = "jobFileGatewayTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobFileGatewayTransactionManager") public Long heartBeat(FileWorkerDTO fileWorkerDTO) { Long id; String configStr = fileWorkerDTO.getConfigStr(); diff --git a/src/backend/job-logsvr/api-job-logsvr/src/main/java/com/tencent/bk/job/logsvr/model/service/ServiceExecuteObjectScriptLogDTO.java b/src/backend/job-logsvr/api-job-logsvr/src/main/java/com/tencent/bk/job/logsvr/model/service/ServiceExecuteObjectScriptLogDTO.java index 3458229de8..4b185ae209 100644 --- a/src/backend/job-logsvr/api-job-logsvr/src/main/java/com/tencent/bk/job/logsvr/model/service/ServiceExecuteObjectScriptLogDTO.java +++ b/src/backend/job-logsvr/api-job-logsvr/src/main/java/com/tencent/bk/job/logsvr/model/service/ServiceExecuteObjectScriptLogDTO.java @@ -79,6 +79,12 @@ public class ServiceExecuteObjectScriptLogDTO { @ApiModelProperty("日志偏移 - 字节") private Integer offset; + /** + * 日志大小 - 字节 + */ + @ApiModelProperty("日志大小 - 字节") + private Integer contentSizeBytes = 0; + /** * 日志内容 */ @@ -89,11 +95,12 @@ public class ServiceExecuteObjectScriptLogDTO { /** * Constructor * - * @param hostId 主机hostId - * @param cloudIp 主机ipv4,格式: 云区域ID:IPv4 - * @param cloudIpv6 主机ipv6,格式: 云区域ID:IPv6 - * @param content 日志内容 - * @param offset 日志偏移量 + * @param hostId 主机hostId + * @param cloudIp 主机ipv4,格式: 云区域ID:IPv4 + * @param cloudIpv6 主机ipv6,格式: 云区域ID:IPv6 + * @param content 日志内容 + * @param contentSizeBytes 日志内容大小(单位byte) + * @param offset 日志偏移量 */ @Deprecated @CompatibleImplementation(name = "execute_object", deprecatedVersion = "3.9.x", type = CompatibleType.HISTORY_DATA) @@ -101,26 +108,31 @@ public ServiceExecuteObjectScriptLogDTO(Long hostId, String cloudIp, String cloudIpv6, String content, + int contentSizeBytes, int offset) { this.hostId = hostId; this.cloudIp = cloudIp; this.cloudIpv6 = cloudIpv6; this.content = content; + this.contentSizeBytes = contentSizeBytes; this.offset = offset; } /** * Constructor * - * @param executeObjectId 执行对象 ID - * @param content 日志内容 - * @param offset 日志偏移量 + * @param executeObjectId 执行对象 ID + * @param content 日志内容 + * @param contentSizeBytes 日志内容大小(单位byte) + * @param offset 日志偏移量 */ public ServiceExecuteObjectScriptLogDTO(String executeObjectId, String content, + int contentSizeBytes, int offset) { this.executeObjectId = executeObjectId; this.content = content; + this.contentSizeBytes = contentSizeBytes; this.offset = offset; } } diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/TaskTemplateCreateUpdateReq.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/TaskTemplateCreateUpdateReq.java index ff2c90064a..18f868b6c4 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/TaskTemplateCreateUpdateReq.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/TaskTemplateCreateUpdateReq.java @@ -46,9 +46,6 @@ import java.util.List; import java.util.Set; -/** - * @since 15/10/2019 20:27 - */ @Slf4j @Data @EqualsAndHashCode(callSuper = true) diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskFileStepVO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskFileStepVO.java index fc55afc762..f8c1f86711 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskFileStepVO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskFileStepVO.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.tencent.bk.job.common.constant.DuplicateHandlerEnum; import com.tencent.bk.job.common.constant.ErrorCode; +import com.tencent.bk.job.common.constant.JobConstants; import com.tencent.bk.job.common.constant.NotExistPathHandlerEnum; import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.common.util.FilePathValidateUtil; @@ -38,9 +39,6 @@ import java.util.List; -/** - * @since 16/10/2019 14:46 - */ @Data @ApiModel("步骤文件信息") @Slf4j @@ -127,7 +125,7 @@ public void validate(boolean isCreate) throws InvalidParamException { throw new InvalidParamException(ErrorCode.ILLEGAL_PARAM); } if (timeout == null || timeout < 0) { - timeout = 0L; + timeout = (long) JobConstants.DEFAULT_JOB_TIMEOUT_SECONDS; } if (originSpeedLimit == null || originSpeedLimit <= 0) { originSpeedLimit = null; diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskScriptStepVO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskScriptStepVO.java index 2e3ae1e52b..e6872af0d0 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskScriptStepVO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskScriptStepVO.java @@ -35,9 +35,6 @@ import org.apache.commons.lang3.StringUtils; import org.hibernate.validator.constraints.Range; -/** - * @since 16/10/2019 14:46 - */ @Data @ApiModel("任务脚本步骤信息") @Slf4j @@ -120,9 +117,6 @@ public void validate(boolean isCreate) throws InvalidParamException { if (StringUtils.isNotBlank(scriptParam) && scriptParam.length() > 5000) { scriptParam = scriptParam.substring(0, 5000); } - if (timeout == null) { - timeout = 3600L; - } if (ignoreError == null || ignoreError < 0) { ignoreError = 0; } diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskStepVO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskStepVO.java index 6f41d3ab61..02757253f9 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskStepVO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/task/TaskStepVO.java @@ -42,9 +42,6 @@ import javax.validation.Valid; import java.util.List; -/** - * @since 16/10/2019 10:37 - */ @Data @ApiModel("任务步骤信息") @Slf4j diff --git a/src/backend/job-manage/service-job-manage/build.gradle b/src/backend/job-manage/service-job-manage/build.gradle index 7448558124..93ef049c91 100644 --- a/src/backend/job-manage/service-job-manage/build.gradle +++ b/src/backend/job-manage/service-job-manage/build.gradle @@ -39,6 +39,7 @@ dependencies { api project(":commons:esb-sdk") api project(":commons:gse-sdk") api project(":commons:cmdb-sdk") + api project(":commons:common-mysql") implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.boot:spring-boot-starter-jdbc" implementation "org.springframework.boot:spring-boot-starter-jooq" diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceAccountResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceAccountResourceImpl.java index 9c679f7795..bc8fff5d0e 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceAccountResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceAccountResourceImpl.java @@ -33,6 +33,7 @@ import com.tencent.bk.job.common.model.InternalResponse; import com.tencent.bk.job.common.model.Response; import com.tencent.bk.job.common.model.dto.AppResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.service.AppScopeMappingService; import com.tencent.bk.job.common.util.ArrayUtil; import com.tencent.bk.job.common.util.date.DateUtils; @@ -45,7 +46,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; @@ -135,7 +135,7 @@ private ServiceAccountDTO toServiceAccountDTO(AccountDTO accountDTO) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public InternalResponse saveOrGetAccount(String username, Long createTime, Long lastModifyTime, String lastModifyUser, Long appId, AccountCreateUpdateReq accountCreateUpdateReq) { diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceScriptResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceScriptResourceImpl.java index 3f4290c50c..d44e11b617 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceScriptResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceScriptResourceImpl.java @@ -29,6 +29,7 @@ import com.tencent.bk.job.common.exception.NotFoundException; import com.tencent.bk.job.common.i18n.service.MessageI18nService; import com.tencent.bk.job.common.model.InternalResponse; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.ArrayUtil; import com.tencent.bk.job.manage.api.common.ScriptDTOBuilder; import com.tencent.bk.job.manage.api.inner.ServiceScriptResource; @@ -41,7 +42,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; @RestController @@ -99,7 +99,7 @@ public InternalResponse getScriptByScriptVersionId(Long script } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public InternalResponse> createScriptWithVersionId(String username, Long createTime, Long lastModifyTime, String lastModifyUser, Integer scriptStatus, Long appId, diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskPlanResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskPlanResourceImpl.java index 60368856bf..823b0fa420 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskPlanResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskPlanResourceImpl.java @@ -30,6 +30,7 @@ import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.common.exception.NotFoundException; import com.tencent.bk.job.common.model.InternalResponse; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.manage.api.inner.ServiceTaskPlanResource; import com.tencent.bk.job.manage.common.consts.task.TaskFileTypeEnum; @@ -68,7 +69,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; @@ -206,7 +206,7 @@ public InternalResponse getPlanById(Long appId, Long planId, } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public InternalResponse createPlanWithIdForMigration( String username, Long appId, diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskTemplateResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskTemplateResourceImpl.java index 908487bc54..f52f7c89fb 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskTemplateResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/impl/ServiceTaskTemplateResourceImpl.java @@ -34,6 +34,7 @@ import com.tencent.bk.job.common.model.InternalResponse; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.common.model.dto.AppResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.manage.api.inner.ServiceTaskTemplateResource; @@ -59,7 +60,6 @@ import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; @@ -132,7 +132,7 @@ public InternalResponse getTemplateNameById(Long templateId) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public InternalResponse saveTemplateForMigration( String username, Long appId, diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebTaskTemplateResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebTaskTemplateResourceImpl.java index 00e99df1f6..0cd92dd8bb 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebTaskTemplateResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/impl/WebTaskTemplateResourceImpl.java @@ -39,6 +39,7 @@ import com.tencent.bk.job.common.model.Response; import com.tencent.bk.job.common.model.ValidateResult; import com.tencent.bk.job.common.model.dto.AppResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.api.web.WebTaskTemplateResource; import com.tencent.bk.job.manage.auth.TemplateAuthService; import com.tencent.bk.job.manage.common.consts.TemplateTypeEnum; @@ -62,7 +63,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; @@ -256,7 +256,7 @@ public Response createTemplate(String username, } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") @AuditEntry( actionId = ActionId.DELETE_JOB_TEMPLATE, subActionIds = {ActionId.DELETE_JOB_PLAN} diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/config/listener/NotifyInitListener.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/config/listener/NotifyInitListener.java index ebba6abbdb..b46c8e1c50 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/config/listener/NotifyInitListener.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/config/listener/NotifyInitListener.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.manage.config.listener; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.paas.cmsi.CmsiApiClient; import com.tencent.bk.job.common.paas.model.EsbNotifyChannelDTO; import com.tencent.bk.job.common.util.StringUtil; @@ -48,7 +49,6 @@ import org.springframework.context.annotation.Profile; import org.springframework.lang.NonNull; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; @@ -134,7 +134,7 @@ private void initDefaultNotifyChannels() { saveDefaultNotifyChannelsToDb(esbNotifyChannelDTOList); } - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void saveDefaultNotifyChannelsToDb(List esbNotifyChannelDTOList) { if (!globalSettingsService.isNotifyChannelConfiged()) { globalSettingsService.setNotifyChannelConfiged(); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/customsetting/UserCustomSettingDAO.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/customsetting/UserCustomSettingDAO.java index 13ec8bc7fd..dcca7c9d6a 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/customsetting/UserCustomSettingDAO.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/customsetting/UserCustomSettingDAO.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.manage.dao.customsetting; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.ListUtil; import com.tencent.bk.job.manage.model.dto.customsetting.UserCustomSettingDTO; import com.tencent.bk.job.manage.model.tables.UserCustomSetting; @@ -38,7 +39,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Arrays; @@ -60,7 +60,7 @@ public UserCustomSettingDAO(@Qualifier("job-manage-dsl-context") DSLContext dslC this.dslContext = dslContext; } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") public int batchSave(List customSettingList) { List keyList = extractKeyList(customSettingList); Set existKeys = new HashSet<>(listExistKeys(keyList)); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/globalsetting/impl/GlobalSettingDAOImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/globalsetting/impl/GlobalSettingDAOImpl.java index 0884bb827a..e37a5a5e68 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/globalsetting/impl/GlobalSettingDAOImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/globalsetting/impl/GlobalSettingDAOImpl.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.manage.dao.globalsetting.impl; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.dao.globalsetting.GlobalSettingDAO; import com.tencent.bk.job.manage.model.dto.GlobalSettingDTO; import com.tencent.bk.job.manage.model.tables.GlobalSetting; @@ -34,7 +35,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import java.util.concurrent.atomic.AtomicInteger; @@ -52,7 +52,7 @@ public GlobalSettingDAOImpl(@Qualifier("job-manage-dsl-context") DSLContext dslC } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public int upsertGlobalSetting(GlobalSettingDTO globalSettingDTO) { AtomicInteger affectedNum = new AtomicInteger(0); deleteGlobalSetting(globalSettingDTO.getKey()); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/ApplicationHostDAOImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/ApplicationHostDAOImpl.java index 3d18ed5d69..e5a87d1638 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/ApplicationHostDAOImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/ApplicationHostDAOImpl.java @@ -36,6 +36,7 @@ import com.tencent.bk.job.common.model.dto.HostSimpleDTO; import com.tencent.bk.job.common.model.dto.HostStatusNumStatisticsDTO; import com.tencent.bk.job.common.model.dto.ResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.StringUtil; import com.tencent.bk.job.common.util.TagUtils; import com.tencent.bk.job.manage.common.TopologyHelper; @@ -71,7 +72,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; @@ -998,7 +998,7 @@ public int batchUpdateHostsBeforeLastTime(List hostList) { return affectedNum; } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public int deleteHostBeforeOrEqualLastTime(Long bizId, Long hostId, Long lastTime) { int affectedNum; @@ -1019,7 +1019,7 @@ public int deleteHostBeforeOrEqualLastTime(Long bizId, Long hostId, Long lastTim return affectedNum; } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public int batchDeleteHostById(List hostIdList) { if (CollectionUtils.isEmpty(hostIdList)) { @@ -1036,7 +1036,7 @@ public int batchDeleteHostById(List hostIdList) { .execute(); } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public int batchDeleteBizHostInfoById(Long bizId, List hostIdList) { int affectedNum = 0; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/plan/impl/TaskPlanVariableDAOImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/plan/impl/TaskPlanVariableDAOImpl.java index b8057fab7e..2fddf2b985 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/plan/impl/TaskPlanVariableDAOImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/plan/impl/TaskPlanVariableDAOImpl.java @@ -29,6 +29,7 @@ import com.tencent.bk.job.common.constant.TaskVariableTypeEnum; import com.tencent.bk.job.common.crypto.scenario.CipherVariableCryptoService; import com.tencent.bk.job.common.exception.InternalException; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.dao.TaskVariableDAO; import com.tencent.bk.job.manage.model.dto.task.TaskVariableDTO; import com.tencent.bk.job.manage.model.tables.TaskPlanVariable; @@ -48,7 +49,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; @@ -249,7 +249,7 @@ public boolean batchInsertVariableWithId(List variableList) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public boolean updateVariableByName(TaskVariableDTO variable) { List conditions = new ArrayList<>(); conditions.add(TABLE.PLAN_ID.equal(ULong.valueOf(variable.getPlanId()))); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/whiteip/impl/WhiteIPRecordDAOImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/whiteip/impl/WhiteIPRecordDAOImpl.java index ab83c83cee..a9e86d0712 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/whiteip/impl/WhiteIPRecordDAOImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/whiteip/impl/WhiteIPRecordDAOImpl.java @@ -29,6 +29,7 @@ import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.dto.ApplicationDTO; import com.tencent.bk.job.common.model.dto.HostDTO; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.CustomCollectionUtils; import com.tencent.bk.job.manage.common.util.JooqDataTypeUtil; import com.tencent.bk.job.manage.dao.ApplicationDAO; @@ -71,7 +72,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; @@ -142,7 +142,7 @@ private static OrderField buildOrderField(TableField field, Integer ord } @SuppressWarnings("all") - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public Long insertWhiteIPRecord(WhiteIPRecordDTO whiteIPRecordDTO) { //插入Record表 @@ -194,7 +194,7 @@ public Long insertWhiteIPRecord(WhiteIPRecordDTO whiteIPRecordDTO) { return recordId; } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public int deleteWhiteIPRecordById(Long id) { //删关联表 @@ -435,7 +435,7 @@ private Long countWhiteIPRecordByConditions(List conditions) { return query.fetchOne(0, Long.class); } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public int updateWhiteIPRecordById(WhiteIPRecordDTO whiteIPRecordDTO) { //更新Record表 diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/manager/host/HostCache.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/manager/host/HostCache.java index 17610f92ac..d6f525b0bd 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/manager/host/HostCache.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/manager/host/HostCache.java @@ -136,6 +136,8 @@ public void batchDeleteHost(Collection hosts) { */ public void addOrUpdateHost(ApplicationHostDTO applicationHostDTO) { CacheHostDO cacheHost = CacheHostDO.fromApplicationHostDTO(applicationHostDTO); + cacheHost.setCacheTime(System.currentTimeMillis()); + log.info("Update host cache, hostId: {}, host: {}", cacheHost.getHostId(), cacheHost); String hostIpKey = buildHostIpKey(applicationHostDTO); String hostIdKey = buildHostIdKey(applicationHostDTO); redisTemplate.opsForValue().set(hostIpKey, cacheHost, EXPIRE_DAYS, TimeUnit.DAYS); @@ -160,13 +162,7 @@ public void batchAddOrUpdateHosts(List hosts) { redisTemplate.executePipelined(new SessionCallback() { @Override public Object execute(@NotNull RedisOperations operations) throws DataAccessException { - hosts.forEach(host -> { - CacheHostDO cacheHost = CacheHostDO.fromApplicationHostDTO(host); - String hostIpKey = buildHostIpKey(host); - String hostIdKey = buildHostIdKey(host); - operations.opsForValue().set(hostIpKey, cacheHost, EXPIRE_DAYS, TimeUnit.DAYS); - operations.opsForValue().set(hostIdKey, cacheHost, EXPIRE_DAYS, TimeUnit.DAYS); - }); + hosts.forEach(host -> addOrUpdateHost(host)); return null; } }); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/AddHostIdForTemplateAndPlanMigrationTask.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/AddHostIdForTemplateAndPlanMigrationTask.java index 248e5da2c9..7bc5a736ac 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/AddHostIdForTemplateAndPlanMigrationTask.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/AddHostIdForTemplateAndPlanMigrationTask.java @@ -28,6 +28,7 @@ import com.tencent.bk.job.common.constant.TaskVariableTypeEnum; import com.tencent.bk.job.common.exception.InternalException; import com.tencent.bk.job.common.model.dto.ApplicationHostDTO; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.manage.model.dto.task.TaskHostNodeDTO; import com.tencent.bk.job.manage.model.dto.task.TaskTargetDTO; @@ -58,7 +59,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; import java.util.ArrayList; @@ -442,7 +442,7 @@ public List listTaskTargets(List appIdList, Long fromRec } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void updateTaskTargets(List records) { if (CollectionUtils.isEmpty(records)) { return; @@ -648,7 +648,7 @@ public List listTaskTargets(List appIdList, Long fromRec } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void updateTaskTargets(List records) { if (CollectionUtils.isEmpty(records)) { return; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/ResourceTagsMigrationTask.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/ResourceTagsMigrationTask.java index 2baacc7062..7bcf6fddf5 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/ResourceTagsMigrationTask.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/migration/ResourceTagsMigrationTask.java @@ -26,6 +26,7 @@ import com.tencent.bk.job.common.constant.JobResourceTypeEnum; import com.tencent.bk.job.common.model.Response; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.dao.ResourceTagDAO; import com.tencent.bk.job.manage.dao.ScriptDAO; import com.tencent.bk.job.manage.dao.template.TaskTemplateDAO; @@ -36,7 +37,6 @@ import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -92,7 +92,7 @@ public Response> execute() { return Response.buildSuccessResp(resourceTags); } - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void saveResourceTags(List resourceTags) { resourceTagDAO.batchSaveResourceTags(resourceTags); } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/db/CacheHostDO.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/db/CacheHostDO.java index c1c33099d0..0b312f286b 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/db/CacheHostDO.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/db/CacheHostDO.java @@ -30,6 +30,8 @@ import lombok.Getter; import lombok.Setter; +import java.util.StringJoiner; + /** * Redis 缓存主机DO */ @@ -93,6 +95,8 @@ public class CacheHostDO { */ private String osType; + private long cacheTime; + public ApplicationHostDTO toApplicationHostDTO() { ApplicationHostDTO host = new ApplicationHostDTO(); host.setBizId(this.bizId); @@ -124,4 +128,22 @@ public static CacheHostDO fromApplicationHostDTO(ApplicationHostDTO host) { cacheHost.setGseAgentStatus(host.getGseAgentStatus()); return cacheHost; } + + @Override + public String toString() { + return new StringJoiner(", ", CacheHostDO.class.getSimpleName() + "[", "]") + .add("cloudAreaId=" + cloudAreaId) + .add("ip='" + ip + "'") + .add("ipv6='" + ipv6 + "'") + .add("hostId=" + hostId) + .add("agentId='" + agentId + "'") + .add("appId=" + appId) + .add("bizId=" + bizId) + .add("hostDesc='" + hostDesc + "'") + .add("gseAgentStatus=" + gseAgentStatus) + .add("os='" + os + "'") + .add("osType='" + osType + "'") + .add("cacheTime=" + cacheTime) + .toString(); + } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskFileStepDTO.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskFileStepDTO.java index 7fa2da8b01..bde18be047 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskFileStepDTO.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskFileStepDTO.java @@ -26,12 +26,13 @@ import com.tencent.bk.job.common.constant.DuplicateHandlerEnum; import com.tencent.bk.job.common.constant.ErrorCode; +import com.tencent.bk.job.common.constant.JobConstants; import com.tencent.bk.job.common.constant.NotExistPathHandlerEnum; import com.tencent.bk.job.common.esb.model.job.v3.EsbAccountV3BasicDTO; import com.tencent.bk.job.common.esb.model.job.v3.EsbFileDestinationV3DTO; +import com.tencent.bk.job.common.esb.model.job.v3.resp.EsbFileStepV3DTO; import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.execute.common.constants.FileTransferModeEnum; -import com.tencent.bk.job.common.esb.model.job.v3.resp.EsbFileStepV3DTO; import com.tencent.bk.job.manage.model.inner.ServiceAccountDTO; import com.tencent.bk.job.manage.model.inner.ServiceTaskFileStepDTO; import com.tencent.bk.job.manage.model.web.vo.task.TaskFileDestinationInfoVO; @@ -116,7 +117,8 @@ public static TaskFileStepDTO fromVO(Long stepId, TaskFileStepVO fileStepVO) { fileStep.setExecuteAccount(fileStepVO.getFileDestination().getAccount()); fileStep.setDestinationHostList(TaskTargetDTO.fromVO(fileStepVO.getFileDestination().getServer())); } - fileStep.setTimeout(fileStepVO.getTimeout()); + fileStep.setTimeout(fileStepVO.getTimeout() == null ? + (long) JobConstants.DEFAULT_JOB_TIMEOUT_SECONDS : fileStepVO.getTimeout()); fileStep.setOriginSpeedLimit(fileStepVO.getOriginSpeedLimit()); fileStep.setTargetSpeedLimit(fileStepVO.getTargetSpeedLimit()); if (fileStepVO.getTransferMode() != null) { diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskScriptStepDTO.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskScriptStepDTO.java index cc9bdc8630..36533a5cc3 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskScriptStepDTO.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/task/TaskScriptStepDTO.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.manage.model.dto.task; +import com.tencent.bk.job.common.constant.JobConstants; import com.tencent.bk.job.common.esb.model.job.v3.EsbAccountV3BasicDTO; import com.tencent.bk.job.common.esb.model.job.v3.resp.EsbScriptStepV3DTO; import com.tencent.bk.job.common.util.Base64Util; @@ -125,7 +126,7 @@ public static TaskScriptStepDTO fromVO(Long stepId, TaskScriptStepVO scriptStepV scriptStep.setLanguage(ScriptTypeEnum.valOf(scriptStepVO.getScriptLanguage())); scriptStep.setScriptParam(scriptStepVO.getScriptParam()); if (scriptStepVO.getTimeout() == null) { - scriptStep.setTimeout(60L); + scriptStep.setTimeout((long) JobConstants.DEFAULT_JOB_TIMEOUT_SECONDS); } else { scriptStep.setTimeout(scriptStepVO.getTimeout()); } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/AbstractTaskStepService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/AbstractTaskStepService.java index 6d53aa72e3..83445f7d5e 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/AbstractTaskStepService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/AbstractTaskStepService.java @@ -29,6 +29,7 @@ import com.tencent.bk.job.common.exception.InternalException; import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.common.exception.ServiceException; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.manage.common.consts.task.TaskFileTypeEnum; import com.tencent.bk.job.manage.common.consts.task.TaskScriptSourceEnum; @@ -49,7 +50,6 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; @@ -160,7 +160,7 @@ private void fillRefScriptContent(Map scriptStepMap) { * @return 新增的步骤 ID * @throws ServiceException 新增步骤异常 */ - @Transactional(value = "jobManageTransactionManager", rollbackFor = ServiceException.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public long insertStep(TaskStepDTO taskStep) throws ServiceException { try { Long stepId = taskStepDAO.insertStep(taskStep); @@ -240,7 +240,7 @@ public long insertStep(TaskStepDTO taskStep) throws ServiceException { * @return 是否更新成功 * @throws ServiceException 更新异常 */ - @Transactional(value = "jobManageTransactionManager", rollbackFor = ServiceException.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public boolean updateStepById(TaskStepDTO taskStep) throws ServiceException { try { if (taskStepDAO.updateStepById(taskStep)) { @@ -328,7 +328,7 @@ public boolean updateStepById(TaskStepDTO taskStep) throws ServiceException { * @return 是否删除成功 * @throws ServiceException 删除异常 */ - @Transactional(value = "jobManageTransactionManager", rollbackFor = ServiceException.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public boolean deleteStepById(Long parentId, Long id) throws ServiceException { try { TaskStepDTO taskStep = taskStepDAO.getStepById(parentId, id); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/host/impl/HostServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/host/impl/HostServiceImpl.java index 337765b59f..6c0729e485 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/host/impl/HostServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/host/impl/HostServiceImpl.java @@ -36,6 +36,7 @@ import com.tencent.bk.job.common.model.dto.HostDTO; import com.tencent.bk.job.common.model.dto.HostSimpleDTO; import com.tencent.bk.job.common.model.dto.ResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.ip.IpUtils; import com.tencent.bk.job.manage.common.TopologyHelper; @@ -51,7 +52,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; import java.util.ArrayList; @@ -183,7 +183,7 @@ public int updateHostsStatus(List simpleHostList) { return updateCount; } - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @Override public Pair createOrUpdateHostBeforeLastTime(ApplicationHostDTO hostInfoDTO) { boolean needToCreate = false; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/DangerousRuleServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/DangerousRuleServiceImpl.java index 97453b3e1e..c28cc839a3 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/DangerousRuleServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/DangerousRuleServiceImpl.java @@ -29,6 +29,7 @@ import com.tencent.bk.job.common.constant.ErrorCode; import com.tencent.bk.job.common.exception.InternalException; import com.tencent.bk.job.common.iam.constant.ActionId; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.common.consts.EnableStatusEnum; import com.tencent.bk.job.manage.dao.globalsetting.DangerousRuleDAO; import com.tencent.bk.job.manage.manager.cache.DangerousRuleCache; @@ -41,7 +42,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; @@ -113,7 +113,7 @@ public DangerousRuleDTO updateDangerousRule(String username, AddOrUpdateDangerou @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.HIGH_RISK_DETECT_RULE, content = EventContentConstants.EDIT_HIGH_RISK_DETECT_RULE @@ -173,7 +173,7 @@ public Integer moveDangerousRule(String username, MoveDangerousRuleReq req) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.HIGH_RISK_DETECT_RULE, content = EventContentConstants.DELETE_HIGH_RISK_DETECT_RULE 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 c0577cb9c2..fa5930cb80 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 @@ -33,6 +33,7 @@ import com.tencent.bk.job.common.i18n.locale.LocaleUtils; import com.tencent.bk.job.common.i18n.service.MessageI18nService; import com.tencent.bk.job.common.iam.constant.ActionId; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.notice.config.BkNoticeProperties; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.StringUtil; @@ -95,7 +96,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.info.BuildProperties; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; @@ -698,7 +698,7 @@ public Map getJobConfig(String username) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Throwable.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.GLOBAL_SETTINGS, content = EventContentConstants.EDIT_GLOBAL_SETTINGS diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptManagerImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptManagerImpl.java index 90085b7233..035d3e613f 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptManagerImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptManagerImpl.java @@ -37,6 +37,7 @@ import com.tencent.bk.job.common.iam.model.AuthResult; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.common.model.dto.AppResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.JobUUID; import com.tencent.bk.job.common.util.date.DateUtils; import com.tencent.bk.job.common.util.json.JsonUtils; @@ -74,7 +75,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; @@ -370,7 +370,7 @@ public ScriptDTO updateScriptVersion(ScriptDTO scriptVersion) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public Pair createScriptWithVersionId( Long appId, ScriptDTO script, @@ -447,7 +447,7 @@ public void saveScriptVersionToDB(ScriptDTO script) { } @Override - @Transactional(rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void deleteScriptVersion(Long appId, Long scriptVersionId) { ScriptDTO existScript = scriptDAO.getScriptVersionById(scriptVersionId); checkDeleteScriptPermission(appId, existScript); @@ -469,7 +469,7 @@ private void checkScriptReferenced(ScriptDTO script) { } @Override - @Transactional(rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void deleteScript(Long appId, String scriptId) { ScriptDTO existScript = getScript(appId, scriptId); checkDeleteScriptPermission(appId, existScript); @@ -915,7 +915,7 @@ private void fillSyncResultDetail(Long syncScriptVersionId, List listPageTags(TagDTO tagQuery, BaseSearchCondition baseSe } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.MANAGE_TAG, instance = @AuditInstanceRecord( @@ -352,7 +352,7 @@ public boolean batchSaveResourceTags(List resourceTags) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void batchPatchResourceTags(List addResourceTags, List deleteResourceTags) { StopWatch watch = new StopWatch("batchPatchResourceTags"); 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 0310a34e55..33a228d626 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 @@ -31,6 +31,7 @@ import com.tencent.bk.job.common.iam.constant.ActionId; import com.tencent.bk.job.common.model.dto.UserRoleInfoDTO; import com.tencent.bk.job.common.model.vo.NotifyChannelVO; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.redis.util.LockUtils; import com.tencent.bk.job.common.util.Counter; import com.tencent.bk.job.common.util.I18nUtil; @@ -83,7 +84,6 @@ import org.slf4j.helpers.MessageFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; import java.time.LocalDateTime; @@ -264,7 +264,7 @@ private void saveTriggerPolicy(String operator, } @Override - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") public Long saveAppDefaultNotifyPoliciesToLocal(String operator, Long appId, String triggerUser, NotifyPoliciesCreateUpdateReq createUpdateReq) { val policyList = createUpdateReq.getTriggerPoliciesList(); @@ -391,7 +391,7 @@ public List listAvailableNotifyChannel(String username) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public Integer setAvailableNotifyChannel(String username, SetAvailableNotifyChannelReq req) { List channelCodeList = Arrays.asList(req.getChannelCodeStr().trim().split(NotifyConsts.SEPERATOR_COMMA)); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanServiceImpl.java index 242639f3b1..1d1e393b86 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanServiceImpl.java @@ -40,6 +40,7 @@ import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.common.model.dto.AppResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.PageUtil; import com.tencent.bk.job.common.util.date.DateUtils; @@ -68,7 +69,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; @@ -285,7 +285,7 @@ public TaskPlanInfoDTO getTaskPlan(String username, Long appId, Long planId) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.CREATE_JOB_PLAN, instance = @AuditInstanceRecord( @@ -360,7 +360,7 @@ private void checkDeletePlanPermission(String username, long appId, long templat } @Override - @Transactional(rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.EDIT_JOB_PLAN, instance = @AuditInstanceRecord( @@ -378,7 +378,7 @@ public TaskPlanInfoDTO updateTaskPlan(String username, TaskPlanInfoDTO taskPlanI } @Override - @Transactional(rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public TaskPlanInfoDTO updateDebugTaskPlan(String username, TaskPlanInfoDTO taskPlanInfo) { // 调试作业模版会保存一份内置的执行方案;从用户角度来说仍然还是在处理跟模版相关的操作,所以使用模版查看鉴权 templateAuthService.authViewJobTemplate(username, @@ -461,7 +461,7 @@ public TaskPlanInfoDTO deleteTaskPlan(String username, Long appId, Long template } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public TaskPlanInfoDTO getDebugTaskPlan(String username, Long appId, Long templateId) { TaskPlanInfoDTO taskPlan = taskPlanDAO.getDebugTaskPlan(appId, templateId); TaskTemplateInfoDTO taskTemplateInfo = taskTemplateService.getTaskTemplateBasicInfoById(appId, templateId); @@ -570,7 +570,7 @@ public Boolean checkPlanName(Long appId, Long templateId, Long planId, String na } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.SYNC_JOB_PLAN, instance = @AuditInstanceRecord( @@ -650,7 +650,7 @@ public Boolean sync(Long appId, Long templateId, Long planId, String templateVer } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void syncPlan(TaskPlanInfoDTO taskPlanInfo) { try { // process plan id @@ -802,7 +802,7 @@ public boolean checkPlanId(Long planId) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public Long saveTaskPlanForBackup(TaskPlanInfoDTO taskPlanInfo) { try { TaskPlanInfoDTO taskPlanByName = taskPlanDAO.getTaskPlanByName(taskPlanInfo.getAppId(), @@ -911,7 +911,7 @@ public Set listLocalFiles() { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.EDIT_JOB_PLAN, instance = @AuditInstanceRecord( diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanVariableServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanVariableServiceImpl.java index 2520015af3..70ba85776f 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanVariableServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/plan/impl/TaskPlanVariableServiceImpl.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.manage.service.plan.impl; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.dao.TaskVariableDAO; import com.tencent.bk.job.manage.model.dto.task.TaskVariableDTO; import com.tencent.bk.job.manage.service.AbstractTaskVariableService; @@ -32,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -54,7 +54,7 @@ public TaskVariableDTO getVariableById(Long parentId, Long id) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public boolean batchUpdateVariableByName(List variableList) { if (CollectionUtils.isEmpty(variableList)) { return false; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TaskTemplateServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TaskTemplateServiceImpl.java index 9ba131eb76..611d1474fe 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TaskTemplateServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TaskTemplateServiceImpl.java @@ -42,6 +42,7 @@ import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.common.model.dto.AppResourceScope; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.redis.util.LockUtils; import com.tencent.bk.job.common.util.JobContextUtil; import com.tencent.bk.job.common.util.PageUtil; @@ -80,7 +81,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; @@ -351,7 +351,7 @@ private void authCreateTemplate(String username, long appId) { } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = ServiceException.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.CREATE_JOB_TEMPLATE, instance = @AuditInstanceRecord( @@ -369,7 +369,7 @@ public TaskTemplateInfoDTO saveTaskTemplate(String username, TaskTemplateInfoDTO } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.EDIT_JOB_TEMPLATE, instance = @AuditInstanceRecord( @@ -574,7 +574,7 @@ public void createNewTagForTemplateIfNotExist(TaskTemplateInfoDTO taskTemplateIn } @Override - @Transactional(value = "jobManageTransactionManager") + @JobTransactional(transactionManager = "jobManageTransactionManager") @ActionAuditRecord( actionId = ActionId.DELETE_JOB_TEMPLATE, instance = @AuditInstanceRecord( @@ -737,7 +737,7 @@ public List getFavoredTemplateBasicInfo(Long appId, String } @Override - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public Long saveTaskTemplateForMigration( TaskTemplateInfoDTO taskTemplateInfo, Long createTime, diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TemplateStatusUpdateService.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TemplateStatusUpdateService.java index 6de08c2876..67368914f4 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TemplateStatusUpdateService.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/template/impl/TemplateStatusUpdateService.java @@ -26,6 +26,7 @@ import com.tencent.bk.job.common.constant.ErrorCode; import com.tencent.bk.job.common.exception.InvalidParamException; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.manage.common.consts.JobResourceStatusEnum; import com.tencent.bk.job.manage.dao.template.TaskTemplateDAO; import com.tencent.bk.job.manage.model.dto.ScriptStatusUpdateMessageDTO; @@ -47,7 +48,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashSet; @@ -150,7 +150,7 @@ void doUpdateStatus(String uuid, ScriptStatusUpdateMessageDTO scriptStatusUpdate } } - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void processTemplateStatus(ULong templateId) { Result> records = context.select(STEP_SCRIPT_TABLE.ID, STEP_SCRIPT_TABLE.SCRIPT_VERSION_ID).from(STEP_SCRIPT_TABLE) @@ -226,7 +226,7 @@ private void processScriptStepStatus(Map templateScriptVersionMap, } } - @Transactional(value = "jobManageTransactionManager", rollbackFor = {Exception.class, Error.class}) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void updateTemplateStatus(ULong templateId, int scriptStatus) { taskTemplateDAO.updateTemplateStatus(templateId, scriptStatus); } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/task/EsbUserInfoUpdateTask.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/task/EsbUserInfoUpdateTask.java index 561e3017c2..6d3ec60685 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/task/EsbUserInfoUpdateTask.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/task/EsbUserInfoUpdateTask.java @@ -25,6 +25,7 @@ package com.tencent.bk.job.manage.task; import com.tencent.bk.job.common.model.dto.BkUserDTO; +import com.tencent.bk.job.common.mysql.JobTransactional; import com.tencent.bk.job.common.paas.user.UserMgrApiClient; import com.tencent.bk.job.common.redis.util.LockUtils; import com.tencent.bk.job.common.redis.util.RedisKeyHeartBeatThread; @@ -40,7 +41,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StopWatch; import java.util.ArrayList; @@ -154,7 +154,7 @@ public boolean execute() { return true; } - @Transactional(value = "jobManageTransactionManager", rollbackFor = Throwable.class) + @JobTransactional(transactionManager = "jobManageTransactionManager") public void saveEsbUserInfos(Set deleteSet, Set insertSet) { deleteSet.forEach(esbUserInfoDTO -> esbUserInfoDAO.deleteEsbUserInfoById( esbUserInfoDTO.getId())); diff --git a/src/frontend/src/components/task-step/common/timeout.vue b/src/frontend/src/components/task-step/common/timeout.vue index 17ad62b245..981f41dc44 100644 --- a/src/frontend/src/components/task-step/common/timeout.vue +++ b/src/frontend/src/components/task-step/common/timeout.vue @@ -155,7 +155,7 @@ this.isMouseenter = true; }, handleChange(value) { - this.$emit('on-change', this.field, value); + this.$emit('on-change', this.field, Number(value) > 0 ? Number(value) : null); }, }, }; diff --git a/src/frontend/src/views/executive-history/step-detail/components/ip-list/index-new.vue b/src/frontend/src/views/executive-history/step-detail/components/ip-list/index-new.vue index 697b04f593..441852f3df 100644 --- a/src/frontend/src/views/executive-history/step-detail/components/ip-list/index-new.vue +++ b/src/frontend/src/views/executive-history/step-detail/components/ip-list/index-new.vue @@ -446,8 +446,6 @@ calcPageSize(); tableMaxHeight.value = listRef.value.getBoundingClientRect().height; - console.log('tableMaxHeight = ', tableMaxHeight.value); - window.addEventListener('resize', handleWindowResize); onBeforeUnmount(() => { window.removeEventListener('resize', handleWindowResize); diff --git a/src/frontend/src/views/executive-history/step-detail/components/view-step-info.vue b/src/frontend/src/views/executive-history/step-detail/components/view-step-info.vue deleted file mode 100644 index 2298bb283b..0000000000 --- a/src/frontend/src/views/executive-history/step-detail/components/view-step-info.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - - diff --git a/src/frontend/src/views/executive-history/step-detail/components/view-step-info/components/task-step-detail/exec-script.vue b/src/frontend/src/views/executive-history/step-detail/components/view-step-info/components/task-step-detail/exec-script.vue index 37f0a5b15f..e3f6c9c5d5 100644 --- a/src/frontend/src/views/executive-history/step-detail/components/view-step-info/components/task-step-detail/exec-script.vue +++ b/src/frontend/src/views/executive-history/step-detail/components/view-step-info/components/task-step-detail/exec-script.vue @@ -50,7 +50,7 @@ :lang="language" :options="languageOption" readonly - :value="stepInfo.content" /> + :value="scriptContent" />
@@ -114,8 +114,10 @@ const languageOption = [language]; const stepInfo = shallowRef(props.data.scriptStepInfo); + const executeAccountText = ref(''); const scriptName = ref(''); + const scriptContent = ref(stepInfo.value.content); const scriptInfo = shallowRef({}); const requestQueue = ref([]); @@ -132,10 +134,7 @@ id: stepInfo.value.scriptVersionId, }).then((data) => { scriptName.value = data.name; - stepInfo.value = { - ...stepInfo.value, - content: data.content, - }; + scriptContent.value = data.content; scriptInfo.value = data; }) .finally(() => {