From 1fe5cd45b16ead60fc07c431c21a25ec87d6e4a9 Mon Sep 17 00:00:00 2001 From: carlyin Date: Tue, 7 Jan 2025 12:17:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20taskControl=E7=9A=84loop=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E5=A4=AA=E4=B9=85=E5=AF=BC=E8=87=B4Consumer=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E8=A2=AB=E5=8D=A0=E6=BB=A1=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20#11352?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/control/VmOperateTaskGenerator.kt | 10 +++++++--- .../engine/atom/vm/DispatchVMStartupTaskAtom.kt | 2 +- .../devops/process/engine/control/TaskControl.kt | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/VmOperateTaskGenerator.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/VmOperateTaskGenerator.kt index d803f7ec161..facd7848b6d 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/VmOperateTaskGenerator.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/control/VmOperateTaskGenerator.kt @@ -92,6 +92,7 @@ class VmOperateTaskGenerator { val taskName: String val taskAtom: String var timeout: Long? = null + var timeoutVar: String? = null if (container is VMBuildContainer) { val buildType = container.dispatchType?.buildType()?.name ?: BuildType.DOCKER.name val baseOS = container.baseOS.name @@ -99,19 +100,22 @@ class VmOperateTaskGenerator { taskType = EnvControlTaskType.VM.name taskName = "Prepare_Job#${container.id!!}" taskAtom = START_VM_TASK_ATOM - timeout = container.jobControlOption?.prepareTimeout?.toLong() + timeout = container.jobControlOption?.timeout?.toLong() + timeoutVar = container.jobControlOption?.timeoutVar } else { atomCode = START_NORMAL_TASK_ATOM taskType = EnvControlTaskType.NORMAL.name taskName = "Prepare_Job#${container.id!!}(N)" taskAtom = START_NORMAL_TASK_ATOM if (container is NormalContainer) { - timeout = container.jobControlOption?.prepareTimeout?.toLong() + timeout = container.jobControlOption?.timeout?.toLong() + timeoutVar = container.jobControlOption?.timeoutVar } } val additionalOptions = ElementAdditionalOptions( runCondition = RunCondition.PRE_TASK_FAILED_BUT_CANCEL, - timeout = timeout + timeout = timeout, + timeoutVar = timeoutVar ) return PipelineBuildTask( projectId = projectId, diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/atom/vm/DispatchVMStartupTaskAtom.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/atom/vm/DispatchVMStartupTaskAtom.kt index 3aedb903f5f..a95960a6538 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/atom/vm/DispatchVMStartupTaskAtom.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/atom/vm/DispatchVMStartupTaskAtom.kt @@ -230,7 +230,7 @@ class DispatchVMStartupTaskAtom @Autowired constructor( ) dispatch(task, pipelineInfo!!, param, vmNames, container!!, ignoreEnvAgentIds, pipelineAuthorizer) logger.info("[$buildId]|STARTUP_VM|VM=${param.baseOS}-$vmNames($vmSeqId)|Dispatch startup") - return AtomResponse(BuildStatus.CALL_WAITING) + return AtomResponse(BuildStatus.RUNNING) } private fun dispatch( diff --git a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/TaskControl.kt b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/TaskControl.kt index 28345c393c1..79ee6108d49 100644 --- a/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/TaskControl.kt +++ b/src/backend/ci/core/process/biz-engine/src/main/kotlin/com/tencent/devops/process/engine/control/TaskControl.kt @@ -40,6 +40,7 @@ import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatch import com.tencent.devops.process.engine.atom.AtomResponse import com.tencent.devops.process.engine.atom.TaskAtomService import com.tencent.devops.process.engine.common.BS_ATOM_STATUS_REFRESH_DELAY_MILLS +import com.tencent.devops.process.engine.common.VMUtils.getStartVmLabel import com.tencent.devops.process.engine.control.lock.ContainerIdLock import com.tencent.devops.process.engine.pojo.PipelineBuildTask import com.tencent.devops.process.engine.pojo.event.PipelineBuildAtomTaskEvent @@ -175,7 +176,9 @@ class TaskControl @Autowired constructor( if (buildStatus.isRunning()) { // 仍然在运行中--没有结束的 // 如果是要轮循的才需要定时消息轮循 - loopDispatch(buildTask = buildTask) + if (!taskId.startsWith(getStartVmLabel())) { + loopDispatch(buildTask = buildTask) + } } else { pipelineBuildTaskService.finishTask( buildTask = buildTask,