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: 修复流水线事件重放报500错误 #11333 #11348

Merged
merged 2 commits into from
Dec 26, 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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ jobs:
version=`echo $version | sed 's/-/./g'`
major=`echo $version | cut -d. -f1`
minor=`echo $version | cut -d. -f2`
echo "version_file=CHANGELOG/CHANGELOG-$major.$minor.md"
echo "version_file=CHANGELOG/CHANGELOG-$major.$minor.md" >> $GITHUB_OUTPUT
echo "version_file=CHANGELOG/zh_CN/CHANGELOG-$major.$minor.md"
echo "version_file=CHANGELOG/zh_CN/CHANGELOG-$major.$minor.md" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: ncipollo/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ data class StartBuildContext(
*/
private fun fillCascadeParam(
param: BuildParameters,
originStartContexts: HashMap<String, BuildParameters>,
originStartContexts: HashMap<String, BuildParameters>
): List<BuildParameters> {
val originStartParams = mutableListOf<BuildParameters>()
val key = param.key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class PipelineTriggerEventDao {
dslContext.selectFrom(this)
.where(EVENT_ID.eq(eventId))
.and(PROJECT_ID.eq(projectId))
.fetchOne()
.fetchAny()
}
return record?.let { convertEvent(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ class SubPipelineStartUpService @Autowired constructor(
val model = resource.model

val triggerContainer = model.getTriggerContainer()
templateFacadeService.printModifiedTemplateParams(
projectId = projectId, pipelineId = pipelineId,
pipelineParams = triggerContainer.params, paramValues = parameters
)
// #6090 拨乱反正
val params = buildParamCompatibilityTransformer.parseTriggerParam(
userId = userId, projectId = projectId, pipelineId = pipelineId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,6 @@ class PipelineBuildFacadeService(
logger.info("[$pipelineId] buildNo was changed to [$buildNo]")
}

templateFacadeService.printModifiedTemplateParams(
projectId = projectId, pipelineId = pipelineId,
pipelineParams = triggerContainer.params, paramValues = values
)
val paramMap = buildParamCompatibilityTransformer.parseTriggerParam(
userId = userId, projectId = projectId, pipelineId = pipelineId,
paramProperties = triggerContainer.params, paramValues = values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2627,37 +2627,6 @@ class TemplateFacadeService @Autowired constructor(
return pipelineTemplatePermissionService.enableTemplatePermissionManage(projectId)
}

// TODO 埋点统计模板常量在流水线启动时被修改日志, 后续需要删除
fun printModifiedTemplateParams(
projectId: String,
pipelineId: String,
pipelineParams: List<BuildFormProperty>,
paramValues: Map<String, String>
) {
val templatePipelineRecord = templatePipelineDao.get(dslContext, projectId, pipelineId) ?: return
val templateRecord =
templateDao.getTemplate(dslContext = dslContext, version = templatePipelineRecord.version) ?: return
val template: Model = objectMapper.readValue(templateRecord.template)
val templateParams = (template.getTriggerContainer()).templateParams
if (templateParams.isNullOrEmpty()) {
return
}
pipelineParams.forEach { param ->
val value = paramValues[param.id] ?: param.defaultValue
templateParams.forEach { template ->
if (template.id == param.id && template.defaultValue != value) {
logger.warn(
"BKSystemErrorMonitor|$projectId|$pipelineId|" +
"templateId:${templateRecord.id}|templateVersion:${templateRecord.version}|" +
"defaultValue:${template.defaultValue}|newValue:$value|" +
"template params cannot be modified"
)
return
}
}
}
}

companion object {
private val logger = LoggerFactory.getLogger(TemplateFacadeService::class.java)
private const val INIT_TEMPLATE_NAME = "init"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,25 +206,19 @@ class CodeGitRepositoryService @Autowired constructor(
authType = repository.authType,
gitProjectId = gitProjectId
)
val repositoryCodeRecord = repositoryCodeGitDao.get(
dslContext = transactionContext,
repositoryId = repositoryId
)
if (repositoryCodeRecord.authType == RepoAuthType.OAUTH.name &&
repositoryCodeRecord.userName != repository.userName) {
repositoryAuthorizationService.batchModifyHandoverFrom(
projectId = projectId,
resourceAuthorizationHandoverList = listOf(
ResourceAuthorizationHandoverDTO(
projectCode = projectId,
resourceType = AuthResourceType.CODE_REPERTORY.value,
resourceName = record.aliasName,
resourceCode = repositoryHashId,
handoverTo = repository.userName
)
// 重置授权管理
repositoryAuthorizationService.batchModifyHandoverFrom(
projectId = projectId,
resourceAuthorizationHandoverList = listOf(
ResourceAuthorizationHandoverDTO(
projectCode = projectId,
resourceType = AuthResourceType.CODE_REPERTORY.value,
resourceName = record.aliasName,
resourceCode = repositoryHashId,
handoverTo = repository.userName
)
)
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,18 @@ class CodeGithubRepositoryService @Autowired constructor(
repository.userName,
gitProjectId = gitProjectId
)
val githubRepositoryRecord = repositoryGithubDao.get(
dslContext = transactionContext,
repositoryId = repositoryId
)
if (githubRepositoryRecord.userName != repository.userName) {
repositoryAuthorizationService.batchModifyHandoverFrom(
projectId = projectId,
resourceAuthorizationHandoverList = listOf(
ResourceAuthorizationHandoverDTO(
projectCode = projectId,
resourceType = AuthResourceType.CODE_REPERTORY.value,
resourceName = record.aliasName,
resourceCode = repositoryHashId,
handoverTo = repository.userName
)
repositoryAuthorizationService.batchModifyHandoverFrom(
projectId = projectId,
resourceAuthorizationHandoverList = listOf(
ResourceAuthorizationHandoverDTO(
projectCode = projectId,
resourceType = AuthResourceType.CODE_REPERTORY.value,
resourceName = record.aliasName,
resourceCode = repositoryHashId,
handoverTo = repository.userName
)
)
}
)
}
}

Expand Down