Skip to content

Commit

Permalink
feat: taskControl的loop循环太久导致Consumer线程池被占满问题 #11352
Browse files Browse the repository at this point in the history
  • Loading branch information
carlyin0801 committed Jan 7, 2025
1 parent 4eb97e9 commit 1fe5cd4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,30 @@ 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
atomCode = "$START_VM_TASK_ATOM-$buildType-$baseOS"
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1fe5cd4

Please sign in to comment.