Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: 心跳超时被取消的插件没有刷新前端状态 #11265 #11266

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class BuildLogPrinter(
tag = tag,
subTag = subTag,
containerHashId = containerHashId,
logType = LogType.DEBUG,
logType = LogType.WARN,
executeCount = executeCount,
jobId = jobId,
stepId = stepId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
}
Expand Down Expand Up @@ -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
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class PipelineRuntimeService @Autowired constructor(
pipelineId = pipelineId,
userId = userId,
buildId = build.buildId,
status = BuildStatus.TERMINATE
status = BuildStatus.TERMINATE,
executeCount = build.executeCount
)
)
}
Expand Down Expand Up @@ -701,7 +702,8 @@ class PipelineRuntimeService @Autowired constructor(
userId = userId,
buildId = buildId,
status = buildStatus,
actionType = actionType
actionType = actionType,
executeCount = executeCount
),
PipelineBuildCancelBroadCastEvent(
source = "cancelBuild",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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不存在直接取消构建
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down