diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt index 8b7d177f925..a70cb9f8aa4 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/utils/ModelUtils.kt @@ -117,10 +117,11 @@ object ModelUtils { val jobStatus = BuildStatus.parse(c.status) c.canRetry = jobStatus.isFailure() || jobStatus.isCancel() } - - val failElements = mutableListOf() - c.elements.forEach { e -> - refreshElement(element = e, failElements = failElements) + if (c.canRetry == true) { + val failElements = mutableListOf() + c.elements.forEach { e -> + refreshElement(element = e, failElements = failElements) + } } } } diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt index b11580ee1ad..b62e68d8887 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/constant/ProcessMessageCode.kt @@ -143,7 +143,7 @@ object ProcessMessageCode { const val ERROR_TIMEOUT_IN_BUILD_QUEUE = "2101904" // 排队超时,取消运行! [{0}] const val ERROR_PARUS_PIEPLINE_IS_RUNNINT = "2101905" // 暂停的流水线已开始运行 const val ERROR_ELEMENT_TOO_LONG = "2101906" // {0} element大小越界 - const val ERROR_STOP_VM_UN_FINISH = "2101907" // stopVm还未完成,请稍后重试 + const val ERROR_JOB_RUNNING = "2101907" // job非完成态,不能进行重试 const val ERROR_NO_BUILD_EXISTS_BY_ID = "2101100" // 流水线构建[{0}]不存在 const val ERROR_NO_PIPELINE_EXISTS_BY_ID = "2101101" // 流水线[{0}]不存在 diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineInfoDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineInfoDao.kt index ed26a4da7a1..12511786add 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineInfoDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineInfoDao.kt @@ -555,7 +555,7 @@ class PipelineInfoDao { fun listByProject(dslContext: DSLContext, projectCode: String): Result> { return with(T_PIPELINE_INFO) { dslContext.select(PIPELINE_ID.`as`("pipelineId"), ID.`as`("id")).from(this) - .where(PROJECT_ID.eq(projectCode)).fetch() + .where(PROJECT_ID.eq(projectCode).and(DELETE.eq(false))).fetch() } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineRetryFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineRetryFacadeService.kt index a9479fb7abc..db130bfc759 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineRetryFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineRetryFacadeService.kt @@ -33,6 +33,7 @@ import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatch import com.tencent.devops.common.event.enums.ActionType import com.tencent.devops.common.log.utils.BuildLogPrinter import com.tencent.devops.common.pipeline.enums.BuildStatus +import com.tencent.devops.common.service.utils.MessageCodeUtil import com.tencent.devops.process.constant.ProcessMessageCode import com.tencent.devops.process.engine.common.VMUtils import com.tencent.devops.process.engine.pojo.PipelineBuildContainer @@ -122,33 +123,17 @@ class PipelineRetryFacadeService @Autowired constructor( ) } - // 若当前job的关机任务还未完成,报错让用户稍后再重试。否则会因为开机比关机早到引发引擎调度问题 + // 若当前job状态还未完成,报错让用户稍后再重试。否则会因为开机比关机早到引发引擎调度问题 private fun checkStopTask( projectId: String, buildId: String, containerInfo: PipelineBuildContainer ) { - var jobFinish = true if (!containerInfo.status.isFinish()) { - val runningTasks = pipelineTaskService.listContainerBuildTasks( - projectId = projectId, - buildId = buildId, - containerSeqId = containerInfo.containerId, - buildStatusSet = setOf(BuildStatus.RUNNING) - ) - runningTasks.forEach { - if (it.taskId.startsWith(VMUtils.getStopVmLabel()) || it.taskId.startsWith(VMUtils.getEndLabel())) { - jobFinish = false - return@forEach - } - } - } - - if (!jobFinish) { - logger.warn("retry runningJob: $projectId|$buildId stopVm not finish") + logger.warn("retry runningJob: $projectId|$buildId|${containerInfo.containerId} is running") throw ErrorCodeException( - errorCode = ProcessMessageCode.ERROR_STOP_VM_UN_FINISH, - defaultMessage = "$buildId|${containerInfo.containerId} stopVm未完成,请稍后重试" + errorCode = ProcessMessageCode.ERROR_JOB_RUNNING, + defaultMessage = MessageCodeUtil.getCodeLanMessage(ProcessMessageCode.ERROR_JOB_RUNNING) ) } } diff --git a/support-files/sql/5001_ci_project-init_dml_mysql.sql b/support-files/sql/5001_ci_project-init_dml_mysql.sql index 482473655a5..3548f759c86 100755 --- a/support-files/sql/5001_ci_project-init_dml_mysql.sql +++ b/support-files/sql/5001_ci_project-init_dml_mysql.sql @@ -171,7 +171,7 @@ REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESS REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_EN`) VALUES ('b6d9420993954802884f474828cc0db1', '2101904', '01', '流水线:排队超时,取消运行! [{0}]', 'Pipeline: Queue timed out, canceled running! [{0}]'); REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_EN`) VALUES ('7d8f2d20b939448f91550967d5ff63b6', '2101905', '01', '流水线:暂停的流水线已开始运行', 'Pipeline: Pipeline: puase pipeline running now'); REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_EN`) VALUES ('4e6d9a9c3c874c16b2fcff32b6a731fd', '2101906', '01', '流水线:{0} element大小越界', 'Pipeline: Pipeline: {0} element size too long'); -REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_EN`) VALUES ('894102da867c431baf9fca6bfd6bc640', '2101907', '01', '流水线: stopVm还未完成,请稍后重试', 'Pipeline: stopVm running, please wait...'); +REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_EN`) VALUES ('894102da867c431baf9fca6bfd6bc640', '2101907', '01', '流水线: job非完成态,不能进行重试', 'Pipeline: job is running, forbid retry'); REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_EN`) VALUES ('a1d8bb8bc3e54b0daaf6d22daef17650', '2101908', '01', '流水线:质量红线(准入)配置有误:Fail to find quality gate intercept element', 'Pipeline: The quality red line (access) is incorrectly configured: Fail to find quality gate intercept element');