From 64a62f9e62ff7d5e5edc925b77d628bd778a07e6 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 28 Nov 2024 19:30:56 +0800 Subject: [PATCH 1/4] =?UTF-8?q?bug:=20=E5=BF=83=E8=B7=B3=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E5=8F=96=E6=B6=88=E7=9A=84=E6=8F=92=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=B7=E6=96=B0=E5=89=8D=E7=AB=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=20#11265?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/container/impl/StartActionTaskContainerCmd.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt index 177f45ca6fe3..61343b828b57 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/command/container/impl/StartActionTaskContainerCmd.kt @@ -389,6 +389,11 @@ class StartActionTaskContainerCmd( BuildStatus.UNEXEC } pipelineTaskService.updateTaskStatus(task = this, userId = starter, buildStatus = taskStatus) + taskBuildRecordService.updateTaskStatus( + projectId = projectId, pipelineId = pipelineId, buildId = buildId, + stageId = stageId, containerId = containerId, taskId = taskId, + executeCount = executeCount ?: 1, buildStatus = taskStatus, operation = "taskNeedTerminate" + ) // 打印构建日志 message.append( I18nUtil.getCodeLanMessage( From 272994f8d85da39a1978d04da8b68b580b77d5db Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 28 Nov 2024 19:36:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?bug:=20=E5=BF=83=E8=B7=B3=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E5=8F=96=E6=B6=88=E7=9A=84=E6=8F=92=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=B7=E6=96=B0=E5=89=8D=E7=AB=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=20#11265?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/common/log/utils/BuildLogPrinter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/common/log/utils/BuildLogPrinter.kt b/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/common/log/utils/BuildLogPrinter.kt index 24c2c06fc809..815bc7220777 100644 --- a/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/common/log/utils/BuildLogPrinter.kt +++ b/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/common/log/utils/BuildLogPrinter.kt @@ -237,7 +237,7 @@ class BuildLogPrinter( tag = tag, subTag = subTag, containerHashId = containerHashId, - logType = LogType.DEBUG, + logType = LogType.WARN, executeCount = executeCount, jobId = jobId, stepId = stepId From dce90f7821254528f3fadc035e598b6f6bd926da Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 28 Nov 2024 20:49:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?bug:=20=E5=BF=83=E8=B7=B3=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E5=8F=96=E6=B6=88=E7=9A=84=E6=8F=92=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=B7=E6=96=B0=E5=89=8D=E7=AB=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=20#11265?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/service/PipelineContainerService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineContainerService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineContainerService.kt index b9243b239aa6..6a7138c22d57 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineContainerService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineContainerService.kt @@ -579,7 +579,7 @@ class PipelineContainerService @Autowired constructor( container.startVMTaskSeq = startVMTaskSeq // 构建矩阵永远跟随stage重试,在需要重试的stage中,单独增加重试记录 - if (context.needRerunStage(stage = stage) && container.matrixGroupFlag == true) { + if (container.matrixGroupFlag == true && !context.needSkipWhenStageFailRetry(stage = stage)) { container.retryFreshMatrixOption() cleanContainersInMatrixGroup( transactionContext = dslContext, From dadcbac4dc568d370dd035563250ef4d85ffd964 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 28 Nov 2024 21:04:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?bug:=20=E5=BF=83=E8=B7=B3=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E5=8F=96=E6=B6=88=E7=9A=84=E6=8F=92=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=B7=E6=96=B0=E5=89=8D=E7=AB=AF=E7=8A=B6=E6=80=81?= =?UTF-8?q?=20#11265=20=E4=BF=AE=E5=A4=8D=E5=8F=96=E6=B6=88=E4=B8=8D?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/interceptor/QueueInterceptor.kt | 6 ++++-- .../process/engine/pojo/event/PipelineBuildCancelEvent.kt | 1 + .../devops/process/engine/service/PipelineRuntimeService.kt | 6 ++++-- .../devops/process/engine/control/BuildCancelControl.kt | 5 +++++ .../devops/process/engine/control/BuildStartControl.kt | 3 ++- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/interceptor/QueueInterceptor.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/interceptor/QueueInterceptor.kt index f61d44dc7468..0ee26a820bca 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/interceptor/QueueInterceptor.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/interceptor/QueueInterceptor.kt @@ -201,7 +201,8 @@ class QueueInterceptor @Autowired constructor( pipelineId = pipelineId, userId = latestStartUser ?: task.pipelineInfo.creator, buildId = buildInfo.buildId, - status = BuildStatus.CANCELED + status = BuildStatus.CANCELED, + executeCount = buildInfo.executeCount ) ) } @@ -255,7 +256,8 @@ class QueueInterceptor @Autowired constructor( pipelineId = pipelineId, userId = latestStartUser ?: task.pipelineInfo.creator, buildId = buildInfo.buildId, - status = BuildStatus.CANCELED + status = BuildStatus.CANCELED, + executeCount = buildInfo.executeCount ) ) } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/pojo/event/PipelineBuildCancelEvent.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/pojo/event/PipelineBuildCancelEvent.kt index 6fe4dfa5d1a7..0e09ffc11e38 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/pojo/event/PipelineBuildCancelEvent.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/pojo/event/PipelineBuildCancelEvent.kt @@ -47,6 +47,7 @@ data class PipelineBuildCancelEvent( val buildId: String, val status: BuildStatus = BuildStatus.CANCELED, val buildNum: Int? = null, + val executeCount: Int?, override var actionType: ActionType = ActionType.END, override var delayMills: Int = 2000 ) : IPipelineEvent(actionType, source, projectId, pipelineId, userId, delayMills) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt index 9d9c88ca1dc8..9f6bd9fdd09b 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt @@ -212,7 +212,8 @@ class PipelineRuntimeService @Autowired constructor( pipelineId = pipelineId, userId = userId, buildId = build.buildId, - status = BuildStatus.TERMINATE + status = BuildStatus.TERMINATE, + executeCount = build.executeCount ) ) } @@ -701,7 +702,8 @@ class PipelineRuntimeService @Autowired constructor( userId = userId, buildId = buildId, status = buildStatus, - actionType = actionType + actionType = actionType, + executeCount = executeCount ), PipelineBuildCancelBroadCastEvent( source = "cancelBuild", diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildCancelControl.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildCancelControl.kt index f3eda3eb0789..3fa9189adec2 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildCancelControl.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildCancelControl.kt @@ -118,6 +118,11 @@ class BuildCancelControl @Autowired constructor( LOG.info("[$$buildId|${event.source}|REPEAT_CANCEL_EVENT|${event.status}| abandon!") return false } + // 执行次数不匹配的时间直接丢弃,防止异步延迟 + if (event.executeCount?.let { buildInfo.executeCount != it } == true) { + LOG.info("[$$buildId|${event.source}|EXECUTE_COUNT_NOT_MATCH|${event.status}| abandon!") + return false + } val model = pipelineBuildDetailService.getBuildModel(projectId = event.projectId, buildId = buildId) return if (model != null) { diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildStartControl.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildStartControl.kt index fe5ce51f6940..33bb10f026a0 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildStartControl.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/BuildStartControl.kt @@ -773,7 +773,8 @@ class BuildStartControl @Autowired constructor( pipelineEventDispatcher.dispatch( PipelineBuildCancelEvent( source = TAG, projectId = projectId, pipelineId = pipelineId, - userId = userId, buildId = buildId, status = BuildStatus.UNEXEC + userId = userId, buildId = buildId, status = BuildStatus.UNEXEC, + executeCount = executeCount ) ) return // model不存在直接取消构建