Skip to content

Commit

Permalink
Merge pull request #10917 from tangruotian/issue-10915
Browse files Browse the repository at this point in the history
AgentId复用类型转换问题 #10915
  • Loading branch information
irwinsun authored Sep 6, 2024
2 parents 2df1ddf + 3d8a444 commit 2a21c33
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ThirdPartyDispatchService @Autowired constructor(
)
}

buildByAgentId(dispatchMessage, dispatchType.copy(displayName = agentId, agentType = AgentType.ID))
buildByAgentId(dispatchMessage, dispatchType.copy(displayName = agentId))
}

is ThirdPartyAgentEnvDispatchType -> {
Expand Down Expand Up @@ -341,18 +341,21 @@ class ThirdPartyDispatchService @Autowired constructor(
} catch (e: Exception) {
logger.error("inQueue|doAgentInQueue|error", e)
}
} else if (redisOperation.get(lockKey) != null) {
// 没有复用逻辑的需要检查下如果这个机器剩一个可调度空间且有复用锁那么不能进行调度
val checkRes = if (dockerInfo != null) {
((agent.dockerParallelTaskCount ?: 4) -
thirdPartyAgentBuildService.getDockerRunningBuilds(agent.agentId)) <= 1
} else {
((agent.parallelTaskCount ?: 4) -
thirdPartyAgentBuildService.getRunningBuilds(agent.agentId)) <= 1
}
if (checkRes) {
logAgentReuse(lockKey, dispatchMessage, agent)
return false
} else {
val lockedBuildId = redisOperation.get(lockKey)
if (!lockedBuildId.isNullOrBlank() && lockedBuildId != event.buildId) {
// 没有复用逻辑的需要检查下如果这个机器剩一个可调度空间且有复用锁那么不能进行调度
val checkRes = if (dockerInfo != null) {
((agent.dockerParallelTaskCount ?: 4) -
thirdPartyAgentBuildService.getDockerRunningBuilds(agent.agentId)) <= 1
} else {
((agent.parallelTaskCount ?: 4) -
thirdPartyAgentBuildService.getRunningBuilds(agent.agentId)) <= 1
}
if (checkRes) {
logAgentReuse(lockKey, dispatchMessage, agent)
return false
}
}
}

Expand Down

0 comments on commit 2a21c33

Please sign in to comment.